X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Flogin.php;h=a4e8b33cd9e1b062d2b2f013fa11a6b2ab861019;hb=4b0abe0ce7fd8c9e2cc8ddf52f76cd4c93a5f279;hp=4795dfdbd64939a5a1ca800e322ebde224c66122;hpb=a654d63eb0ade36954afd1ea2026d9b11a0e96fd;p=quix0rs-gnu-social.git diff --git a/actions/login.php b/actions/login.php index 4795dfdbd6..a4e8b33cd9 100644 --- a/actions/login.php +++ b/actions/login.php @@ -1,18 +1,18 @@ . */ @@ -20,10 +20,10 @@ if (!defined('LACONICA')) { exit(1); } class LoginAction extends Action { - + function handle($args) { parent::handle($args); - if (common_logged_in()) { + if (common_is_real_login()) { common_user_error(_t('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->check_login(); @@ -38,42 +38,67 @@ class LoginAction extends Action { $nickname = $this->arg('nickname'); $password = $this->arg('password'); if (common_check_user($nickname, $password)) { - common_set_user($nickname); - common_redirect(common_local_url('all', - array('nickname' => - $nickname))); + # success! + if (!common_set_user($nickname)) { + common_server_error(_t('Error setting user.')); + return; + } + common_real_login(true); + if ($this->boolean('rememberme')) { + common_debug('Adding rememberme cookie'); + 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->show_form(_t('Incorrect username or password.')); } } - + function show_form($error=NULL) { - - common_show_header(_t('Login')); - if (!is_null($error)) { - common_element('div', array('class' => 'error'), $msg); - } - common_element_start('form', array('method' => 'POST', + common_show_header(_t('Login'), NULL, $error, array($this, 'show_top')); + common_element_start('form', array('method' => 'post', 'id' => 'login', 'action' => common_local_url('login'))); - common_element('label', array('for' => 'username'), - _t('Name')); - common_element('input', array('name' => 'username', - 'type' => 'text', - 'id' => 'username')); - common_element('label', array('for' => 'password'), - _t('Password')); - common_element('input', array('name' => 'password', - 'type' => 'password', - 'id' => 'password')); - common_element('input', array('name' => 'submit', - 'type' => 'submit', - 'id' => 'submit'), - _t('Login')); - common_element('input', array('name' => 'cancel', - 'type' => 'button', - 'id' => 'cancel'), - _t('Cancel')); + common_input('nickname', _t('Nickname')); + common_password('password', _t('Password')); + common_checkbox('rememberme', _t('Remember me'), false, + _t('Automatically login in the future; ' . + 'not for shared computers!')); + common_submit('submit', _t('Login')); common_element_end('form'); + common_element_start('p'); + common_element('a', array('href' => common_local_url('recoverpassword')), + _t('Lost or forgotten password?')); + common_element_end('p'); + common_show_footer(); + } + + function get_instructions() { + return _t('Login with your username and password. ' . + 'Don\'t have a username yet? ' . + '[Register](%%action.register%%) a new account, or ' . + 'try [OpenID](%%action.openidlogin%%). '); + } + + function show_top($error=NULL) { + if ($error) { + common_element('p', 'error', $error); + } else { + $instr = $this->get_instructions(); + $output = common_markup_to_html($instr); + common_element_start('p', 'instructions'); + common_raw($output); + common_element_end('p'); + } } }