take out redundant code from login
This commit is contained in:
parent
8463d23397
commit
2bd52059db
|
@ -96,7 +96,7 @@ class LoginAction extends Action
|
||||||
{
|
{
|
||||||
// XXX: login throttle
|
// XXX: login throttle
|
||||||
|
|
||||||
// CSRF protection - token set in common_notice_form()
|
// CSRF protection - token set in NoticeForm
|
||||||
$token = $this->trimmed('token');
|
$token = $this->trimmed('token');
|
||||||
if (!$token || $token != common_session_token()) {
|
if (!$token || $token != common_session_token()) {
|
||||||
$this->clientError(_('There was a problem with your session token. '.
|
$this->clientError(_('There was a problem with your session token. '.
|
||||||
|
@ -106,35 +106,14 @@ class LoginAction extends Action
|
||||||
|
|
||||||
$nickname = common_canonical_nickname($this->trimmed('nickname'));
|
$nickname = common_canonical_nickname($this->trimmed('nickname'));
|
||||||
$password = $this->arg('password');
|
$password = $this->arg('password');
|
||||||
if (common_check_user($nickname, $password)) {
|
|
||||||
// success!
|
if (!common_check_user($nickname, $password)) {
|
||||||
if (!common_set_user($nickname)) {
|
|
||||||
$this->serverError(_('Error setting user.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
common_real_login(true);
|
|
||||||
if ($this->boolean('rememberme')) {
|
|
||||||
common_debug('Adding rememberme cookie for ' . $nickname);
|
|
||||||
common_rememberme();
|
|
||||||
}
|
|
||||||
// success!
|
|
||||||
$url = common_get_returnto();
|
|
||||||
if ($url) {
|
|
||||||
// We don't have to return to it again
|
|
||||||
common_set_returnto(null);
|
|
||||||
} else {
|
|
||||||
$url = common_local_url('all',
|
|
||||||
array('nickname' =>
|
|
||||||
$nickname));
|
|
||||||
}
|
|
||||||
common_redirect($url);
|
|
||||||
} else {
|
|
||||||
$this->showForm(_('Incorrect username or password.'));
|
$this->showForm(_('Incorrect username or password.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// success!
|
// success!
|
||||||
if (!common_set_user($user)) {
|
if (!common_set_user($nickname)) {
|
||||||
$this->serverError(_('Error setting user.'));
|
$this->serverError(_('Error setting user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -142,11 +121,11 @@ class LoginAction extends Action
|
||||||
common_real_login(true);
|
common_real_login(true);
|
||||||
|
|
||||||
if ($this->boolean('rememberme')) {
|
if ($this->boolean('rememberme')) {
|
||||||
common_debug('Adding rememberme cookie for ' . $nickname);
|
|
||||||
common_rememberme($user);
|
common_rememberme($user);
|
||||||
}
|
}
|
||||||
// success!
|
|
||||||
$url = common_get_returnto();
|
$url = common_get_returnto();
|
||||||
|
|
||||||
if ($url) {
|
if ($url) {
|
||||||
// We don't have to return to it again
|
// We don't have to return to it again
|
||||||
common_set_returnto(null);
|
common_set_returnto(null);
|
||||||
|
@ -155,6 +134,7 @@ class LoginAction extends Action
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$nickname));
|
$nickname));
|
||||||
}
|
}
|
||||||
|
|
||||||
common_redirect($url);
|
common_redirect($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user