]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/login.php
Added a configuration option to disable OpenID.
[quix0rs-gnu-social.git] / actions / login.php
index 71e4679292c79102dd97f80f6683a655dfef5535..6f1b4777e5ddb2f8960ab4a80c4e8e61480922de 100644 (file)
@@ -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();
@@ -108,13 +112,15 @@ class LoginAction extends Action
         $nickname = common_canonical_nickname($this->trimmed('nickname'));
         $password = $this->arg('password');
 
-        if (!common_check_user($nickname, $password)) {
+        $user = common_check_user($nickname, $password);
+
+        if (!$user) {
             $this->showForm(_('Incorrect username or password.'));
             return;
         }
 
         // success!
-        if (!common_set_user($nickname)) {
+        if (!common_set_user($user)) {
             $this->serverError(_('Error setting user.'));
             return;
         }
@@ -136,7 +142,7 @@ class LoginAction extends Action
                                           $nickname));
         }
 
-        common_redirect($url);
+        common_redirect($url, 303);
     }
 
     /**
@@ -245,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.');
         }
     }