Repository: ampache/ampache (language: php)

Issue:
LDAP not able to create user
## Description
Creating users who logged into LDAP for the first time does not work.  

### Describe the bug
When a user logs in with LDAP credentials, the user gets a message that reads "Unable to create a local account".

### To reproduce

Steps to reproduce the behavior:

1. Configure LDAP support
2. Try to log in with an LDAP user that has never logged in before.
3. See "Unable to crate a local account" message.

### Expected behavior
I expected the user to be created

### Screenshots
![image](https://user-images.githubusercontent.com/8419000/182233184-c46c4935-1257-4df5-9da9-04e6f809201a.png)

## Environment

* Ampache version: Develop DOCKER version

### Client type

* Web
* Ampache
* SubSonic
* DAAP
* UPnP
* WebDAV

## Logs
~~~
2022-08-01T14:45:37-05:00 [ampache] (Ampache\Module\Authentication\Ldap\Ldap) -> Return value of authentication: {"success":true,"type":"ldap","username":"user@ampache.org","name":"Max Carpenter","email":"user@ampache.org"}
2022-08-01T14:45:37-05:00 [ampache] (Ampache\Module\System\Dba) -> Error_query SQL: INSERT INTO `user` (`username`, `disabled`, `fullname`, `email`, `password`, `access`, `catalog_filter_group`, `create_date`) VALUES(?, ?, ?, ?, ?, ?, ?, ?) ["user@ampache.org",0,"Max Carpenter","user@ampache.org","f8e09d22047e7122cb0b2c239016da8d786c71ec6a604e352216e1ab21f7f4e0",25,"",1659383137]
2022-08-01T14:45:37-05:00 [ampache] (Ampache\Module\System\Dba) -> Error_query MSG: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `ampache`.`user`.`catalog_filter_group` at row 1
2022-08-01T14:45:37-05:00 [ampache] (Ampache\Module\System\Dba) -> Error_query SQL: INSERT INTO `user` (`username`, `disabled`, `fullname`, `email`, `password`, `access`, `catalog_filter_group`, `create_date`) VALUES(?, ?, ?, ?, ?, ?, ?, ?) ["user@ampache.org",0,"Max Carpenter","user@ampache.org","f8e09d22047e7122cb0b2c239016da8d786c71ec6a604e352216e1ab21f7f4e0",25,"",1659383137]
2022-08-01T14:45:37-05:00 [ampache] (Ampache\Module\System\Dba) -> Error_query MSG: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `ampache`.`user`.`catalog_filter_group` at row 1
2022-08-01T14:45:37-05:00 [ampache] (Ampache\Module\System\Dba) -> Error_query SQL: INSERT INTO `user` (`username`, `disabled`, `fullname`, `email`, `password`, `access`, `catalog_filter_group`, `create_date`) VALUES(?, ?, ?, ?, ?, ?, ?, ?) ["user@ampache.org",0,"Max Carpenter","user@ampache.org","f8e09d22047e7122cb0b2c239016da8d786c71ec6a604e352216e1ab21f7f4e0",25,"",1659383137]
2022-08-01T14:45:37-05:00 [ampache] (Ampache\Module\System\Dba) -> Error_query MSG: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `ampache`.`user`.`catalog_filter_group` at row 1
2022-08-01T14:45:37-05:00 [ampache] (Ampache\Module\System\Dba) -> Error_query SQL: INSERT INTO `user` (`username`, `disabled`, `fullname`, `email`, `password`, `access`, `catalog_filter_group`, `create_date`) VALUES(?, ?, ?, ?, ?, ?, ?, ?) ["user@ampache.org",0,"Max Carpenter","user@ampache.org","f8e09d22047e7122cb0b2c239016da8d786c71ec6a604e352216e1ab21f7f4e0",25,"",1659383137]
2022-08-01T14:45:37-05:00 [ampache] (Ampache\Module\System\Dba) -> Error_query MSG: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '' for column `ampache`.`user`.`catalog_filter_group` at row 1
2022-08-01T14:45:37-05:00 [ampache] (Ampache\Module\Application\Login\DefaultAction) -> Unable to create a local account
2022-08-01T14:45:37-05:00 [ampache] (Ampache\Module\System\Session) -> Writing to 93k9d349eflckq8ei2t1g8vage with expiration 1659386737
2022-08-01T14:45:47-05:00 [ampache] (Ampache\Module\System\Dba) -> Database connection...
~~~


Discussion / hints:
A very crude work around for me since I have a small number of users is to pre-create the user in Ampache with any password (since I don't know their LDAP passwords).  Then the LDAP module will allow the user to log in with their LDAP credentials.  
The problem is related to the new catalog feature.  The SQL is:
~~~
INSERT INTO `user` (`username`, `disabled`, `fullname`, `email`, `password`, `access`, `catalog_filter_group`, `create_date`)
VALUES("user@ampache.org",0,"Max Carpenter","user@ampache.org","pw",25,"",1659383137);
~~~
The value for `catalog_filter_group` is "", but should be the number zero (the default catalog filter group)
src/Module/Application/Login/DefaultAction.php Line 236 should be:
~~~
$user_id = User::create($username, $fullname, $email, $website, hash('sha256', bin2hex(random_bytes(20))), $access, 0, $state, $city);
~~~
The zero needs to be added to the call.

Fix patch:
diff --git a/src/Module/Application/Login/DefaultAction.php b/src/Module/Application/Login/DefaultAction.php
index 2462e8328b..1598b0afe7 100644
--- a/src/Module/Application/Login/DefaultAction.php
+++ b/src/Module/Application/Login/DefaultAction.php
@@ -231,9 +231,10 @@ public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gat
                 $website  = array_key_exists('website', $auth) ? $auth['website'] : '';
                 $state    = array_key_exists('state', $auth) ? $auth['state'] : '';
                 $city     = array_key_exists('city', $auth) ? $auth['city'] : '';
+                $dfg      = 0; // This is the default filter group
 
                 // Attempt to create the user
-                $user_id = User::create($username, $fullname, $email, $website, hash('sha256', bin2hex(random_bytes(20))), $access, $state, $city);
+                $user_id = User::create($username, $fullname, $email, $website, hash('sha256', bin2hex(random_bytes(20))), $access, $dfg, $state, $city);
                 if ($user_id > 0) {
                     // tell me you're creating the user
                     $this->logger->info(


Test patch: