]> source.dussan.org Git - nextcloud-server.git/commitdiff
Create users in non default backends first 5511/head
authorJoas Schilling <coding@schilljs.com>
Tue, 20 Jun 2017 17:59:41 +0000 (19:59 +0200)
committerArthur Schiwon <blizzz@arthur-schiwon.de>
Thu, 22 Jun 2017 11:02:53 +0000 (13:02 +0200)
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>
lib/private/User/Manager.php

index 0477f23e552e0227b8ca746721e5f287f6460063..c04f426c2cf6e33de82c6586cfd844dd95d6c9b0 100644 (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);
                        }