X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Flogin.php;h=71e4679292c79102dd97f80f6683a655dfef5535;hb=28ef2ccf427683837dde29f8b89ea8d5378f287b;hp=9fa501a5d9927f12414cfe5bd8ef7dbd05900277;hpb=f7d6d4448fff25351f3f0d9b4d6d1ee02044e263;p=quix0rs-gnu-social.git diff --git a/actions/login.php b/actions/login.php index 9fa501a5d9..71e4679292 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); } @@ -223,7 +204,7 @@ class LoginAction extends Action 'action' => common_local_url('login'))); $this->elementStart('fieldset'); $this->element('legend', null, _('Login to site')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('nickname', _('Nickname')); $this->elementEnd('li');