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
This commit is contained in:
parent
96042f1e5b
commit
05b46f7828
15
lib/user.php
15
lib/user.php
|
@ -172,7 +172,7 @@ class OC_User {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if user already exists
|
// Check if user already exists
|
||||||
if( self::userExists($uid) ) {
|
if( self::userExistsForCreation($uid) ) {
|
||||||
throw new Exception('The username is already being used');
|
throw new Exception('The username is already being used');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,6 +551,19 @@ class OC_User {
|
||||||
return false;
|
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
|
* disables a user
|
||||||
* @param string $userid the user to disable
|
* @param string $userid the user to disable
|
||||||
|
|
|
@ -26,12 +26,6 @@ if(OC_User::isAdminUser(OC_User::getUser())) {
|
||||||
$username = $_POST["username"];
|
$username = $_POST["username"];
|
||||||
$password = $_POST["password"];
|
$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
|
// Return Success story
|
||||||
try {
|
try {
|
||||||
if (!OC_User::createUser($username, $password)) {
|
if (!OC_User::createUser($username, $password)) {
|
||||||
|
|
|
@ -400,12 +400,6 @@ $(document).ready(function () {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var username = $('#newusername').val();
|
var username = $('#newusername').val();
|
||||||
var password = $('#newuserpassword').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) == '') {
|
if ($.trim(username) == '') {
|
||||||
OC.dialogs.alert(
|
OC.dialogs.alert(
|
||||||
t('settings', 'A valid username must be provided'),
|
t('settings', 'A valid username must be provided'),
|
||||||
|
|
Loading…
Reference in New Issue