Skip to content
Snippets Groups Projects
Commit 59627367 authored by Bart Visscher's avatar Bart Visscher
Browse files

Better check and handling of user creation

parent 4eff27ed
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment