]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Pass username and nickname to autoregister so auth plugins can set the nickname corre...
authorCraig Andrews <candrews@integralblue.com>
Sat, 30 Jan 2010 01:43:16 +0000 (20:43 -0500)
committerCraig Andrews <candrews@integralblue.com>
Sat, 30 Jan 2010 01:43:16 +0000 (20:43 -0500)
Continues fixing what Eric Helgeson pointed out in 01eb4e8f003bf62575ec16dfb6127d7534be9c88

lib/authenticationplugin.php
plugins/LdapAuthentication/LdapAuthenticationPlugin.php
plugins/ReverseUsernameAuthentication/ReverseUsernameAuthenticationPlugin.php

index f7f8f8655b4990017f205446da72cade52827d1b..5be3ea5b90795c360f3865e506f9f265b835135d 100644 (file)
@@ -69,13 +69,17 @@ 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
+    * @param username username (that is used to login and find the user in the authentication provider) of the user to be registered
+    * @param nickname nickname of the user in the SN system. If nickname is null, then set nickname = username
     * @return mixed instance of User, or false (if user couldn't be created)
     */
-    function autoRegister($username)
+    function autoRegister($username, $nickname = null)
     {
+        if(is_null($nickname)){
+            $nickname = $username;
+        }
         $registration_data = array();
-        $registration_data['nickname'] = $username ;
+        $registration_data['nickname'] = $nickname ;
         return User::register($registration_data);
     }
 
@@ -132,7 +136,7 @@ abstract class AuthenticationPlugin extends Plugin
                 //someone already exists with the suggested nickname
                 //not much else we can do
             }else{
-                $user = $this->autoRegister($nickname);
+                $user = $this->autoRegister($nickname, $suggested_nickname);
                 if($user){
                     User_username::register($user,$nickname,$this->provider_name);
                     return false;
index 1755033f178a4bed7e38d728d5b092904c86fc9f..768f0fe7f6ea9353015d7a1102e8c4a92f3c189b 100644 (file)
@@ -96,8 +96,11 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
         }
     }
 
-    function autoRegister($username)
+    function autoRegister($username, $nickname)
     {
+        if(is_null($nickname)){
+            $nickname = $username;
+        }
         $entry = $this->ldap_get_user($username,$this->attributes);
         if($entry){
             $registration_data = array();
@@ -107,6 +110,7 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
             if(isset($registration_data['email']) && !empty($registration_data['email'])){
                 $registration_data['email_confirmed']=true;
             }
+            $registration_data['nickname'] = $nickname;
             //set the database saved password to a random string.
             $registration_data['password']=common_good_rand(16);
             return User::register($registration_data);
index d9d2137f827dded3ade0f7ee6b2de6160a3f2679..dac5a158841a77a483fdd488f852b39dd6a1567a 100644 (file)
@@ -47,10 +47,13 @@ class ReverseUsernameAuthenticationPlugin extends AuthenticationPlugin
         return $username == strrev($password);
     }
 
-    function autoRegister($username)
+    function autoRegister($username, $nickname)
     {
+        if(is_null($nickname)){
+            $nickname = $username;
+        }
         $registration_data = array();
-        $registration_data['nickname'] = $username ;
+        $registration_data['nickname'] = $nickname ;
         return User::register($registration_data);
     }