summaryrefslogtreecommitdiff
path: root/lib/command.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-01-11 16:28:27 -0800
committerEvan Prodromou <evan@status.net>2010-01-11 16:28:27 -0800
commitecb3abf84c8b6e868a523b8e721484cb7a4e0f63 (patch)
treec27d9b8c427e0e64b0cabe9419c640ac8b382c3b /lib/command.php
parenta180658a3bfcf2b7b312058e3aa76e0e2467c2f8 (diff)
parent7e5c15fa80e23d1fb22744553156bcebad716ae8 (diff)
Merge branch '0.9.x' into inblob
Diffstat (limited to 'lib/command.php')
-rw-r--r--lib/command.php24
1 files changed, 8 insertions, 16 deletions
diff --git a/lib/command.php b/lib/command.php
index 67140c348..f846fb823 100644
--- a/lib/command.php
+++ b/lib/command.php
@@ -650,25 +650,17 @@ class LoginCommand extends Command
$channel->error($this->user, _('Login command is disabled'));
return;
}
- $login_token = Login_token::staticGet('user_id',$this->user->id);
- if($login_token){
- $login_token->delete();
- }
- $login_token = new Login_token();
- $login_token->user_id = $this->user->id;
- $login_token->token = common_good_rand(16);
- $login_token->created = common_sql_now();
- $result = $login_token->insert();
- if (!$result) {
- common_log_db_error($login_token, 'INSERT', __FILE__);
- $channel->error($this->user, sprintf(_('Could not create login token for %s'),
- $this->user->nickname));
- return;
+
+ try {
+ $login_token = Login_token::makeNew($this->user);
+ } catch (Exception $e) {
+ $channel->error($this->user, $e->getMessage());
}
+
$channel->output($this->user,
sprintf(_('This link is useable only once, and is good for only 2 minutes: %s'),
- common_local_url('login',
- array('user_id'=>$login_token->user_id, 'token'=>$login_token->token))));
+ common_local_url('otp',
+ array('user_id' => $login_token->user_id, 'token' => $login_token->token))));
}
}