diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-02-08 17:16:18 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-02-08 17:16:18 +0100 |
commit | 05b46f78281e5df49a5c6a0513a37eaf03c3c29d (patch) | |
tree | 66be0588d54982d30c1909f7bc8cd8fe8918eb7f | |
parent | 96042f1e5b343ed75f59fc2997b7e54c07b557da (diff) | |
download | nextcloud-server-05b46f78281e5df49a5c6a0513a37eaf03c3c29d.tar.gz nextcloud-server-05b46f78281e5df49a5c6a0513a37eaf03c3c29d.zip |
on creation only test for existing users if the backend supports user creation
this solves the issue where no users can be created any more if backends are active which always return true on userExists() like WebDAV Auth
-rw-r--r-- | lib/user.php | 15 | ||||
-rw-r--r-- | settings/ajax/createuser.php | 6 | ||||
-rw-r--r-- | settings/js/users.js | 6 |
3 files changed, 14 insertions, 13 deletions
diff --git a/lib/user.php b/lib/user.php index 9dc8cca97a6..76c4c45ee30 100644 --- a/lib/user.php +++ b/lib/user.php @@ -172,7 +172,7 @@ class OC_User { } // Check if user already exists - if( self::userExists($uid) ) { + if( self::userExistsForCreation($uid) ) { throw new Exception('The username is already being used'); } @@ -551,6 +551,19 @@ class OC_User { return false; } + public static function userExistsForCreation($uid) { + foreach(self::$_usedBackends as $backend) { + if(!$backend->implementsActions(OC_USER_BACKEND_CREATE_USER)) + continue; + + $result=$backend->userExists($uid); + if($result===true) { + return true; + } + } + return false; + } + /** * disables a user * @param string $userid the user to disable diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php index 09ef25d92fa..56653bed6bd 100644 --- a/settings/ajax/createuser.php +++ b/settings/ajax/createuser.php @@ -26,12 +26,6 @@ if(OC_User::isAdminUser(OC_User::getUser())) { $username = $_POST["username"]; $password = $_POST["password"]; -// Does the group exist? -if(OC_User::userExists($username)) { - OC_JSON::error(array("data" => array( "message" => "User already exists" ))); - exit(); -} - // Return Success story try { if (!OC_User::createUser($username, $password)) { diff --git a/settings/js/users.js b/settings/js/users.js index 094cddda294..3ab48675f29 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -400,12 +400,6 @@ $(document).ready(function () { event.preventDefault(); var username = $('#newusername').val(); var password = $('#newuserpassword').val(); - if ($('#content table tbody tr').filterAttr('data-uid', username).length > 0) { - OC.dialogs.alert( - t('settings', 'The username is already being used'), - t('settings', 'Error creating user')); - return; - } if ($.trim(username) == '') { OC.dialogs.alert( t('settings', 'A valid username must be provided'), |