summaryrefslogtreecommitdiff
path: root/actions/login.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-02-06 15:38:10 -0500
committerEvan Prodromou <evan@controlyourself.ca>2009-02-06 15:38:10 -0500
commit02d7167906b63d490db3b5c3848accc5235b220f (patch)
tree92323dec8d456fdc737ee3a74c48dedf4cb92bcd /actions/login.php
parentd260d841ebae71acf7bf726f52acaa6391ce1824 (diff)
parent60f737dc1eb2f126bae28ce095bc2d17a22bd7d9 (diff)
Merge branch '0.7.x' into 0.8.x
Diffstat (limited to 'actions/login.php')
-rw-r--r--actions/login.php35
1 files changed, 8 insertions, 27 deletions
diff --git a/actions/login.php b/actions/login.php
index 11cf1f02a..71e467929 100644
--- a/actions/login.php
+++ b/actions/login.php
@@ -78,6 +78,7 @@ class LoginAction extends Action
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->checkLogin();
} else {
+ common_ensure_session();
$this->showForm();
}
}
@@ -96,7 +97,7 @@ class LoginAction extends Action
{
// XXX: login throttle
- // CSRF protection - token set in common_notice_form()
+ // CSRF protection - token set in NoticeForm
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->clientError(_('There was a problem with your session token. '.
@@ -106,35 +107,14 @@ class LoginAction extends Action
$nickname = common_canonical_nickname($this->trimmed('nickname'));
$password = $this->arg('password');
- if (common_check_user($nickname, $password)) {
- // success!
- 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 {
+
+ if (!common_check_user($nickname, $password)) {
$this->showForm(_('Incorrect username or password.'));
return;
}
// success!
- if (!common_set_user($user)) {
+ if (!common_set_user($nickname)) {
$this->serverError(_('Error setting user.'));
return;
}
@@ -142,11 +122,11 @@ class LoginAction extends Action
common_real_login(true);
if ($this->boolean('rememberme')) {
- common_debug('Adding rememberme cookie for ' . $nickname);
common_rememberme($user);
}
- // success!
+
$url = common_get_returnto();
+
if ($url) {
// We don't have to return to it again
common_set_returnto(null);
@@ -155,6 +135,7 @@ class LoginAction extends Action
array('nickname' =>
$nickname));
}
+
common_redirect($url);
}