diff --git a/lib/user.php b/lib/user.php
index 801ab7f608..31c93740d7 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -182,7 +182,7 @@ class OC_User {
$backend->createUser($uid, $password);
OC_Hook::emit( "OC_User", "post_createUser", array( "uid" => $uid, "password" => $password ));
- return true;
+ return self::userExists($uid);
}
}
return false;
@@ -204,6 +204,9 @@ class OC_User {
foreach(self::$_usedBackends as $backend) {
$backend->deleteUser($uid);
}
+ if (self::userExists($uid)) {
+ return false;
+ }
// We have to delete the user from all groups
foreach( OC_Group::getUserGroups( $uid ) as $i ) {
OC_Group::removeFromGroup( $uid, $i );
diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php
index 16b48c8a9c..addae78517 100644
--- a/settings/ajax/createuser.php
+++ b/settings/ajax/createuser.php
@@ -29,14 +29,17 @@ $username = $_POST["username"];
$password = $_POST["password"];
// Does the group exist?
-if( in_array( $username, OC_User::getUsers())) {
+if(OC_User::userExists($username)) {
OC_JSON::error(array("data" => array( "message" => "User already exists" )));
exit();
}
// Return Success story
try {
- OC_User::createUser($username, $password);
+ if (!OC_User::createUser($username, $password)) {
+ OC_JSON::error(array('data' => array( 'message' => 'User creation failed for '.$username )));
+ exit();
+ }
foreach( $groups as $i ) {
if(!OC_Group::groupExists($i)) {
OC_Group::createGroup($i);
diff --git a/settings/js/users.js b/settings/js/users.js
index 249d529df4..517984f924 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -29,7 +29,6 @@ var UserList={
$('#notification').html(t('users', 'deleted')+' '+uid+''+t('users', 'undo')+'');
$('#notification').data('deleteuser',true);
$('#notification').fadeIn();
-
},
/**
@@ -57,10 +56,11 @@ var UserList={
$('#notification').fadeOut();
$('tr').filterAttr('data-uid', UserList.deleteUid).remove();
UserList.deleteCanceled = true;
- UserList.deleteFiles = null;
if (ready) {
ready();
}
+ } else {
+ oc.dialogs.alert(result.data.message, t('settings', 'Unable to remove user'));
}
}
});
@@ -69,7 +69,7 @@ var UserList={
add:function(username, groups, subadmin, quota, sort) {
var tr = $('tbody tr').first().clone();
- tr.data('uid', username);
+ tr.attr('data-uid', username);
tr.find('td.name').text(username);
var groupsSelect = $('