]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fixes for RegisterThrottle plugin: alt registration methods (OpenID, FBConnect, Twitt...
authorBrion Vibber <brion@pobox.com>
Wed, 5 Jan 2011 20:26:20 +0000 (12:26 -0800)
committerBrion Vibber <brion@pobox.com>
Wed, 5 Jan 2011 20:28:02 +0000 (12:28 -0800)
Added StartRegistrationTry/EndRegistrationTry calls into those three, and moved the actual recording hook to EndUserRegister which is guaranteed to be called from User::register (so we don't need to worry about other auth methods forgetting to call the other UI-code hooks).

plugins/Facebook/FBConnectAuth.php
plugins/OpenID/finishopenidlogin.php
plugins/RegisterThrottle/RegisterThrottlePlugin.php
plugins/TwitterBridge/twitterauthorization.php

index d6d3786261e6ebc6f2ea91224e3966ca66df3423..33c975d6502bf7aadf65f9100b9bcad21e5e648c 100644 (file)
@@ -232,6 +232,10 @@ class FBConnectauthAction extends Action
 
     function createNewUser()
     {
+        if (!Event::handle('StartRegistrationTry', array($this))) {
+            return;
+        }
+
         if (common_config('site', 'closed')) {
             // TRANS: Client error trying to register with registrations not allowed.
             $this->clientError(_m('Registration not allowed.'));
@@ -300,6 +304,8 @@ class FBConnectauthAction extends Action
         common_debug('Facebook Connect Plugin - ' .
                      "Registered new user $user->id from Facebook user $this->fbuid");
 
+        Event::handle('EndRegistrationTry', array($this));
+
         common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
                         303);
     }
index 01dd61edb12002b756c6b9e177147f2a30dcbb2a..6c4e713897118af0d68e9dd8bf2d6f9529904e71 100644 (file)
@@ -247,6 +247,10 @@ class FinishopenidloginAction extends Action
     {
         # FIXME: save invite code before redirect, and check here
 
+        if (!Event::handle('StartRegistrationTry', array($this))) {
+            return;
+        }
+
         if (common_config('site', 'closed')) {
             // TRANS: OpenID plugin message. No new user registration is allowed on the site.
             $this->clientError(_m('Registration not allowed.'));
@@ -362,6 +366,9 @@ class FinishopenidloginAction extends Action
             common_rememberme($user);
         }
         unset($_SESSION['openid_rememberme']);
+
+        Event::handle('EndRegistrationTry', array($this));
+
         common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
                         303);
     }
index 0078d3c6004ad7130d7ccf509dded28d7e62b7e0..e3982427da5053b5400aa7bce0e38a8095339a78 100644 (file)
@@ -167,28 +167,24 @@ class RegisterThrottlePlugin extends Plugin
     }
 
     /**
-     * Called after someone registers.
+     * Called after someone registers, by any means.
      *
      * We record the successful registration and IP address.
      *
-     * @param Action $action Action that is being executed
+     * @param Profile $profile new user's profile
+     * @param User $user new user
      *
      * @return boolean hook value
      *
      */
 
-    function onEndRegistrationTry($action)
+    function onEndUserRegister($profile, $user)
     {
         $ipaddress = $this->_getIpAddress();
 
         if (empty($ipaddress)) {
-            throw new ServerException(_m('Cannot find IP address.'));
-        }
-
-        $user = common_current_user();
-
-        if (empty($user)) {
-            throw new ServerException(_m('Cannot find user after successful registration.'));
+            // User registration can happen from command-line scripts etc.
+            return true;
         }
 
         $reg = new Registration_ip();
index 931a037230b2c26289fbd1cc1ed7fd3ed87647e4..33ef71fcdd645029477216a7001741f6db58573a 100644 (file)
@@ -419,6 +419,10 @@ class TwitterauthorizationAction extends Action
 
     function createNewUser()
     {
+        if (!Event::handle('StartRegistrationTry', array($this))) {
+            return;
+        }
+
         if (common_config('site', 'closed')) {
             $this->clientError(_m('Registration not allowed.'));
             return;
@@ -492,6 +496,8 @@ class TwitterauthorizationAction extends Action
         common_debug('TwitterBridge Plugin - ' .
                      "Registered new user $user->id from Twitter user $this->twuid");
 
+        Event::handle('EndRegistrationTry', array($this));
+
         common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
                         303);
     }