]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/otp.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / actions / otp.php
index acf84aee814216071c5f8087137997275cf88387..143eb6bdc189c05d0362761e1012b9f51e2cd4ff 100644 (file)
@@ -45,7 +45,6 @@ if (!defined('STATUSNET')) {
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
  * @link      http://status.net/
  */
-
 class OtpAction extends Action
 {
     var $user;
@@ -54,46 +53,46 @@ class OtpAction extends Action
     var $returnto;
     var $lt;
 
-    function prepare($args)
+    function prepare(array $args=array())
     {
         parent::prepare($args);
 
         if (common_is_real_login()) {
+            // TRANS: Client error displayed trying to use "one time password login" when already logged in.
             $this->clientError(_('Already logged in.'));
-            return false;
         }
 
         $id = $this->trimmed('user_id');
 
         if (empty($id)) {
+            // TRANS: Client error displayed trying to use "one time password login" without specifying a user.
             $this->clientError(_('No user ID specified.'));
-            return false;
         }
 
-        $this->user = User::staticGet('id', $id);
+        $this->user = User::getKV('id', $id);
 
         if (empty($this->user)) {
+            // TRANS: Client error displayed trying to use "one time password login" without using an existing user.
             $this->clientError(_('No such user.'));
-            return false;
         }
 
         $this->token = $this->trimmed('token');
 
         if (empty($this->token)) {
+            // TRANS: Client error displayed trying to use "one time password login" without specifying a login token.
             $this->clientError(_('No login token specified.'));
-            return false;
         }
 
-        $this->lt = Login_token::staticGet('user_id', $id);
+        $this->lt = Login_token::getKV('user_id', $id);
 
         if (empty($this->lt)) {
+            // TRANS: Client error displayed trying to use "one time password login" without requesting a login token.
             $this->clientError(_('No login token requested.'));
-            return false;
         }
 
         if ($this->lt->token != $this->token) {
+            // TRANS: Client error displayed trying to use "one time password login" while specifying an invalid login token.
             $this->clientError(_('Invalid login token specified.'));
-            return false;
         }
 
         if ($this->lt->modified > time() + Login_token::TIMEOUT) {
@@ -101,8 +100,8 @@ class OtpAction extends Action
             //delete the token as it is useless
             $this->lt->delete();
             $this->lt = null;
+            // TRANS: Client error displayed trying to use "one time password login" while specifying an expired login token.
             $this->clientError(_('Login token expired.'));
-            return false;
         }
 
         $this->rememberme = $this->boolean('rememberme');
@@ -111,14 +110,14 @@ class OtpAction extends Action
         return true;
     }
 
-       function handle($args)
+    function handle(array $args=array())
     {
         parent::handle($args);
 
         // success!
         if (!common_set_user($this->user)) {
+            // TRANS: Server error displayed when a user object could not be created trying to login using "one time password login".
             $this->serverError(_('Error setting user. You are probably not authorized.'));
-            return;
         }
 
         // We're now logged in; disable the lt
@@ -126,6 +125,8 @@ class OtpAction extends Action
         $this->lt->delete();
         $this->lt = null;
 
+        common_real_login(true);
+
         if ($this->rememberme) {
             common_rememberme($this->user);
         }