]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/login.php
type -> address_type
[quix0rs-gnu-social.git] / actions / login.php
index 9f9c473b513d3436316f8b0dd9035f405ca47fda..83fa3ed23c262f9f7a09f7a5166ad1c6c1bfb8f0 100644 (file)
@@ -23,7 +23,7 @@ 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();
@@ -43,28 +43,52 @@ class LoginAction extends Action {
                                common_server_error(_t('Error setting user.'));
                                return;
                        }
+                       common_real_login(true);
+                       if ($this->boolean('rememberme')) {
+                               common_rememberme();
+                       }
                        # success!
-                       common_redirect(common_local_url('all',
-                                                                                        array('nickname' =>
-                                                                                                  $nickname)));
+                       $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_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_input('nickname', _t('Nickname'));
                common_password('password', _t('Password'));
+               common_checkbox('rememberme', _t('Remember me'),
+                               _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 show_top($error=NULL) {
+               if ($error) {
+                       common_element('p', 'error', $error);
+               } else {
+                       common_element('p', 'instructions',
+                                                  _t('Login with your username and password. ' .
+                                                         'Don\'t have a username yet? Choose register above. '));
+               }
+       }
 }