]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Facebook/FBConnectAuth.php
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / plugins / Facebook / FBConnectAuth.php
index d6d3786261e6ebc6f2ea91224e3966ca66df3423..937db56e56f9e35d355175421cdc7bd74080930f 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.'));
@@ -257,13 +261,10 @@ class FBConnectauthAction extends Action
             }
         }
 
-        $nickname = $this->trimmed('newname');
-
-        if (!Validate::string($nickname, array('min_length' => 1,
-                                               'max_length' => 64,
-                                               'format' => NICKNAME_FMT))) {
-            $this->showForm(_m('Nickname must have only lowercase letters and numbers and no spaces.'));
-            return;
+        try {
+            $nickname = Nickname::normalize($this->trimmed('newname'));
+        } catch (NicknameException $e) {
+            $this->showForm($e->getMessage());
         }
 
         if (!User::allowed_nickname($nickname)) {
@@ -300,6 +301,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);
     }
@@ -447,9 +450,7 @@ class FBConnectauthAction extends Action
 
     function isNewNickname($str)
     {
-        if (!Validate::string($str, array('min_length' => 1,
-                                          'max_length' => 64,
-                                          'format' => NICKNAME_FMT))) {
+        if (!Nickname::isValid($str)) {
             return false;
         }
         if (!User::allowed_nickname($str)) {