]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OpenID/actions/finishopenidlogin.php
Merge branch 'master' of git.gnu.io:gnu/gnu-social into nightly
[quix0rs-gnu-social.git] / plugins / OpenID / actions / finishopenidlogin.php
index 4326f1951461a954017aebcb30dceb7ca3a6b78e..f91d10d252bdcc792bfc5e33cba59a28424e671c 100644 (file)
@@ -29,9 +29,9 @@ class FinishopenidloginAction extends Action
     var $username = null;
     var $message = null;
 
-    function handle($args)
+    function handle()
     {
-        parent::handle($args);
+        parent::handle();
         if (common_is_real_login()) {
             // TRANS: Client error message trying to log on with OpenID while already logged on.
             $this->clientError(_m('Already logged in.'));
@@ -322,7 +322,6 @@ class FinishopenidloginAction extends Action
         if (common_config('site', 'closed')) {
             // TRANS: OpenID plugin message. No new user registration is allowed on the site.
             $this->clientError(_m('Registration not allowed.'));
-            return;
         }
 
         $invite = null;
@@ -332,7 +331,6 @@ class FinishopenidloginAction extends Action
             if (empty($code)) {
                 // TRANS: OpenID plugin message. No new user registration is allowed on the site without an invitation code, and none was provided.
                 $this->clientError(_m('Registration not allowed.'));
-                return;
             }
 
             $invite = Invitation::getKV($code);
@@ -340,35 +338,21 @@ class FinishopenidloginAction extends Action
             if (empty($invite)) {
                 // TRANS: OpenID plugin message. No new user registration is allowed on the site without an invitation code, and the one provided was not valid.
                 $this->clientError(_m('Not a valid invitation code.'));
-                return;
             }
         }
 
         try {
-            $nickname = Nickname::normalize($this->trimmed('newname'));
+            $nickname = Nickname::normalize($this->trimmed('newname'), true);
         } catch (NicknameException $e) {
             $this->showForm($e->getMessage());
             return;
         }
 
-        if (!User::allowed_nickname($nickname)) {
-            // TRANS: OpenID plugin message. The entered new user name is blacklisted.
-            $this->showForm(_m('Nickname not allowed.'));
-            return;
-        }
-
-        if (User::getKV('nickname', $nickname)) {
-            // TRANS: OpenID plugin message. The entered new user name is already used.
-            $this->showForm(_m('Nickname already in use. Try another one.'));
-            return;
-        }
-
         list($display, $canonical, $sreg) = $this->getSavedValues();
 
         if (!$display || !$canonical) {
             // TRANS: OpenID plugin server error. A stored OpenID cannot be retrieved.
             $this->serverError(_m('Stored OpenID not found.'));
-            return;
         }
 
         // Possible race condition... let's be paranoid
@@ -378,7 +362,6 @@ class FinishopenidloginAction extends Action
         if ($other) {
             // TRANS: OpenID plugin server error.
             $this->serverError(_m('Creating new account for OpenID that already has a user.'));
-            return;
         }
 
         Event::handle('StartOpenIDCreateNewUser', array($canonical, &$sreg));
@@ -430,8 +413,7 @@ class FinishopenidloginAction extends Action
 
         Event::handle('EndRegistrationTry', array($this));
 
-        common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)),
-                        303);
+        common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)), 303);
     }
 
     function connectUser()
@@ -454,7 +436,6 @@ class FinishopenidloginAction extends Action
         if (!$display || !$canonical) {
             // TRANS: OpenID plugin server error. A stored OpenID cannot be found.
             $this->serverError(_m('Stored OpenID not found.'));
-            return;
         }
 
         $result = oid_link_user($user->id, $canonical, $display);
@@ -462,7 +443,6 @@ class FinishopenidloginAction extends Action
         if (!$result) {
             // TRANS: OpenID plugin server error. The user or user profile could not be saved.
             $this->serverError(_m('Error connecting user to OpenID.'));
-            return;
         }
 
         if (Event::handle('StartOpenIDUpdateUser', array($user, $canonical, &$sreg))) {
@@ -500,8 +480,8 @@ class FinishopenidloginAction extends Action
         // Try the passed-in nickname
 
         if (!empty($sreg['nickname'])) {
-            $nickname = $this->nicknamize($sreg['nickname']);
-            if ($this->isNewNickname($nickname)) {
+            $nickname = common_nicknamize($sreg['nickname']);
+            if (Nickname::isValid($nickname, true)) {
                 return $nickname;
             }
         }
@@ -509,8 +489,8 @@ class FinishopenidloginAction extends Action
         // Try the full name
 
         if (!empty($sreg['fullname'])) {
-            $fullname = $this->nicknamize($sreg['fullname']);
-            if ($this->isNewNickname($fullname)) {
+            $fullname = common_nicknamize($sreg['fullname']);
+            if (Nickname::isValid($fullname, true)) {
                 return $fullname;
             }
         }
@@ -519,7 +499,7 @@ class FinishopenidloginAction extends Action
 
         $from_url = $this->openidToNickname($display);
 
-        if ($from_url && $this->isNewNickname($from_url)) {
+        if ($from_url && Nickname::isValid($from_url, true)) {
             return $from_url;
         }
 
@@ -528,20 +508,6 @@ class FinishopenidloginAction extends Action
         return null;
     }
 
-    function isNewNickname($str)
-    {
-        if (!Nickname::isValid($str)) {
-            return false;
-        }
-        if (!User::allowed_nickname($str)) {
-            return false;
-        }
-        if (User::getKV('nickname', $str)) {
-            return false;
-        }
-        return true;
-    }
-
     function openidToNickname($openid)
     {
         if (Auth_Yadis_identifierScheme($openid) == 'XRI') {
@@ -570,7 +536,7 @@ class FinishopenidloginAction extends Action
             // =evan.prodromou
             // or @gratis*evan.prodromou
             $parts = explode('*', substr($base, 1));
-            return $this->nicknamize(array_pop($parts));
+            return common_nicknamize(array_pop($parts));
         }
     }
 
@@ -582,10 +548,4 @@ class FinishopenidloginAction extends Action
             return $xri;
         }
     }
-
-    // Given a string, try to make it work as a nickname
-    function nicknamize($str)
-    {
-        return common_nicknamize($str);
-    }
 }