X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Flogin.php;h=6f1b4777e5ddb2f8960ab4a80c4e8e61480922de;hb=7dc3a90d1252137859a687e32313ea569dcf8796;hp=7a3c6d3748435780c93e466008ad4c0fb8b401d6;hpb=4ced74dc9105884fc05d4ab48e8d0162204f8c6a;p=quix0rs-gnu-social.git diff --git a/actions/login.php b/actions/login.php index 7a3c6d3748..6f1b4777e5 100644 --- a/actions/login.php +++ b/actions/login.php @@ -55,7 +55,7 @@ class LoginAction extends Action * @return boolean false */ - function isReadOnly() + function isReadOnly($args) { return false; } @@ -65,6 +65,8 @@ class LoginAction extends Action * * Switches on request method; either shows the form or handles its input. * + * Checks if only OpenID is allowed and redirects to openidlogin if so. + * * @param array $args $_REQUEST data * * @return void @@ -73,7 +75,9 @@ class LoginAction extends Action function handle($args) { parent::handle($args); - if (common_is_real_login()) { + if (common_config('site', 'openidonly')) { + common_redirect(common_local_url('openidlogin')); + } else if (common_is_real_login()) { $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->checkLogin(); @@ -97,7 +101,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. '. @@ -107,29 +111,10 @@ 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 { + + $user = common_check_user($nickname, $password); + + if (!$user) { $this->showForm(_('Incorrect username or password.')); return; } @@ -143,11 +128,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); @@ -156,7 +141,8 @@ class LoginAction extends Action array('nickname' => $nickname)); } - common_redirect($url); + + common_redirect($url, 303); } /** @@ -265,11 +251,15 @@ class LoginAction extends Action return _('For security reasons, please re-enter your ' . 'user name and password ' . 'before changing your settings.'); - } else { + } else if (common_config('openid', 'enabled')) { return _('Login with your username and password. ' . 'Don\'t have a username yet? ' . '[Register](%%action.register%%) a new account, or ' . 'try [OpenID](%%action.openidlogin%%). '); + } else { + return _('Login with your username and password. ' . + 'Don\'t have a username yet? ' . + '[Register](%%action.register%%) a new account.'); } }