]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apiaccountregister.php
Email notify-on-fave moved to Profile_prefs (run upgrade.php)
[quix0rs-gnu-social.git] / actions / apiaccountregister.php
index 9ce7bcfb685e236229854f9372172fca42784698..9926fc8cf933762c0fd476c94203214d086a0588 100644 (file)
@@ -54,7 +54,7 @@ class ApiAccountRegisterAction extends ApiAction
      *
      * @return boolean success flag
      */
-    protected function prepare($args)
+    protected function prepare(array $args=array())
     {
         parent::prepare($args);
 
@@ -102,7 +102,7 @@ class ApiAccountRegisterAction extends ApiAction
         }
 
         if (!empty($this->code)) {
-            $this->invite = Invitation::staticGet('code', $this->code);
+            $this->invite = Invitation::getKV('code', $this->code);
             if (empty($this->invite)) {
             // TRANS: Client error displayed when trying to register to an invite-only site without a valid invitation.
                    $this->clientError(_('Sorry, invalid invitation code.'), 401);
@@ -114,22 +114,17 @@ class ApiAccountRegisterAction extends ApiAction
 
         // Input scrubbing
         try {
-            $nickname = Nickname::normalize($nickname);
+            $nickname = Nickname::normalize($nickname, true);
         } catch (NicknameException $e) {
             // clientError handles Api exceptions with various formats and stuff
-               $this->clientError(_('Not a valid nickname.'), 400);
+               $this->clientError($e->getMessage(), $e->getCode());
         }
+
         $email = common_canonical_email($email);
 
            if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
             // TRANS: Form validation error displayed when trying to register without a valid e-mail address.
                $this->clientError(_('Not a valid email address.'), 400);
-        } else if ($this->nicknameExists($nickname)) {
-            // TRANS: Form validation error displayed when trying to register with an existing nickname.
-               $this->clientError(_('Nickname already in use. Try another one.'), 400);
-        } else if (!User::allowed_nickname($nickname)) {
-            // TRANS: Form validation error displayed when trying to register with an invalid nickname.
-               $this->clientError(_('Not a valid nickname.'), 400);
         } else if ($this->emailExists($email)) {
             // TRANS: Form validation error displayed when trying to register with an already registered e-mail address.
                $this->clientError(_('Email address already exists.'), 400);
@@ -186,22 +181,6 @@ class ApiAccountRegisterAction extends ApiAction
                }                   
         } 
     }
-      
-
-    /**
-     * Does the given nickname already exist?
-     *
-     * Checks a canonical nickname against the database.
-     *
-     * @param string $nickname nickname to check
-     *
-     * @return boolean true if the nickname already exists
-     */
-    function nicknameExists($nickname)
-    {
-        $user = User::staticGet('nickname', $nickname);
-        return is_object($user);
-    }
 
     /**
      * Does the given email address already exist?
@@ -218,7 +197,7 @@ class ApiAccountRegisterAction extends ApiAction
         if (!$email || strlen($email) == 0) {
             return false;
         }
-        $user = User::staticGet('email', $email);
+        $user = User::getKV('email', $email);
         return is_object($user);
     }