]> source.dussan.org Git - nextcloud-server.git/commitdiff
Better check and handling of user creation
authorBart Visscher <bartv@thisnet.nl>
Wed, 14 Nov 2012 20:44:44 +0000 (21:44 +0100)
committerBart Visscher <bartv@thisnet.nl>
Wed, 14 Nov 2012 20:52:28 +0000 (21:52 +0100)
lib/user.php
settings/ajax/createuser.php

index 801ab7f608da99569c9263a83ed7d17cc00f41c5..872fff9b2d9dde02fd2a5775f82a892c6b354554 100644 (file)
@@ -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;
index 16b48c8a9ca058bd0ed1ee177094e93bb7152746..addae78517a45c51de930517355eb8a41ba42d23 100644 (file)
@@ -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);