]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Allow an authentication plugin with the same provider_name other than the one that...
authorCraig Andrews <candrews@integralblue.com>
Mon, 4 Jan 2010 18:33:52 +0000 (13:33 -0500)
committerCraig Andrews <candrews@integralblue.com>
Mon, 4 Jan 2010 18:35:11 +0000 (13:35 -0500)
Allows for SSO-type plugins that don't have any information about the user other than their username to do autoregistration

plugins/Authentication/AuthenticationPlugin.php

index a76848b04e09f5bb4fe4a0473b840a971e9de35c..75e8d2b766cea3f9f49e866b8ead912a95345767 100644 (file)
@@ -99,6 +99,23 @@ abstract class AuthenticationPlugin extends Plugin
         }
     }
 
+    /**
+    * Internal AutoRegister event handler
+    * @param nickname
+    * @param provider_name
+    * @param user - the newly registered user
+    */
+    function onAutoRegister($nickname, $provider_name, &$user)
+    {
+        if($provider_name == $this->provider_name && $this->autoregistration){
+            $user = $this->autoregister($nickname);
+            if($user){
+                User_username::register($user,$nickname,$this->provider_name);
+                return false;
+            }
+        }
+    }
+
     function onStartCheckPassword($nickname, $password, &$authenticatedUser){
         //map the nickname to a username
         $user_username = new User_username();
@@ -127,13 +144,10 @@ abstract class AuthenticationPlugin extends Plugin
                     }
                 }
             }else{
-                if($this->autoregistration){
-                    $authenticated = $this->checkPassword($nickname, $password);
-                    if($authenticated){
-                        $user = $this->autoregister($nickname);
-                        if($user){
-                            $authenticatedUser = $user;
-                            User_username::register($authenticatedUser,$nickname,$this->provider_name);
+                $authenticated = $this->checkPassword($nickname, $password);
+                if($authenticated){
+                    if(Event::handle('AutoRegister', array($nickname, $this->provider_name, &$authenticatedUser))){
+                        if($authenticatedUser){
                             return false;
                         }
                     }