3 class LoginAction extends Action {
5 function handle($args) {
7 if (common_logged_in()) {
8 common_user_error(_t('Already logged in.'));
9 } else if ($this->arg('METHOD') == 'POST') {
16 function check_login() {
17 # XXX: form token in $_SESSION to prevent XSS
19 $nickname = $this->arg('nickname');
20 $password = $this->arg('password');
21 if (common_check_user($nickname, $password)) {
22 common_set_user($nickname);
23 common_redirect(common_local_url('all',
27 $this->show_form(_t('Incorrect username or password.'));
31 function show_form($error=NULL) {
33 common_show_header(_t('Login'));
34 if (!is_null($error)) {
35 common_element('div', array('class' => 'error'), $msg);
37 common_start_element('form', array('method' => 'POST',
39 'action' => common_local_url('login')));
40 common_element('label', array('for' => 'username'),
42 common_element('input', array('name' => 'username',
45 common_element('label', array('for' => 'password'),
47 common_element('input', array('name' => 'password',
50 common_element('input', array('name' => 'submit',
54 common_element('input', array('name' => 'cancel',