Create users in non default backends first

Most of the time, when people have multiple backends or add a
custom backend, they want to create the users there and not in
the default backend. But since that is registered first, users
were always created there.

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-06-20 19:59:41 +02:00 committed by Arthur Schiwon
parent 00256ee18e
commit 7257206bcf
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
1 changed files with 13 additions and 0 deletions

View File

@ -284,7 +284,20 @@ class Manager extends PublicEmitter implements IUserManager {
* @return bool|IUser the created user or false
*/
public function createUser($uid, $password) {
$localBackends = [];
foreach ($this->backends as $backend) {
if ($backend instanceof Database) {
// First check if there is another user backend
$localBackends[] = $backend;
continue;
}
if ($backend->implementsActions(Backend::CREATE_USER)) {
return $this->createUserFromBackend($uid, $password, $backend);
}
}
foreach ($localBackends as $backend) {
if ($backend->implementsActions(Backend::CREATE_USER)) {
return $this->createUserFromBackend($uid, $password, $backend);
}