]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
autoregister returns the new user on success (not just true)
authorCraig Andrews <candrews@integralblue.com>
Fri, 13 Nov 2009 17:54:27 +0000 (12:54 -0500)
committerCraig Andrews <candrews@integralblue.com>
Fri, 13 Nov 2009 17:54:27 +0000 (12:54 -0500)
plugins/Authentication/AuthenticationPlugin.php

index 99b61b808d4cf2f26c1fe2ba59842fcd604c90e4..f061e456d1e65f36c512cdeae31ecc8426e3fcf0 100644 (file)
@@ -70,7 +70,7 @@ abstract class AuthenticationPlugin extends Plugin
     * Automatically register a user when they attempt to login with valid credentials.
     * User::register($data) is a very useful method for this implementation
     * @param username
-    * @return boolean true if the user was created, false if not
+    * @return mixed instance of User, or false (if user couldn't be created)
     */
     function autoRegister($username)
     {
@@ -134,15 +134,18 @@ abstract class AuthenticationPlugin extends Plugin
             }else{
                 if($this->autoregistration){
                     $authenticated = $this->checkPassword($nickname, $password);
-                    if($authenticated && $this->autoregister($nickname)){
-                        $authenticatedUser = User::staticGet('nickname', $nickname);
-                        $user_username = new User_username();
-                        $user_username->user_id = $authenticatedUser->id;
-                        $user_username->provider_name = $this->provider_name;
-                        $user_username->username = $nickname;
-                        $user_username->created = DB_DataObject_Cast::dateTime();
-                        $user_username->insert();
-                        return false;
+                    if($authenticated){
+                        $user = $this->autoregister($nickname);
+                        if($user){
+                            $authenticatedUser = $user;
+                            $user_username = new User_username();
+                            $user_username->user_id = $authenticatedUser->id;
+                            $user_username->provider_name = $this->provider_name;
+                            $user_username->username = $nickname;
+                            $user_username->created = DB_DataObject_Cast::dateTime();
+                            $user_username->insert();
+                            return false;
+                        }
                     }
                 }
             }