From: Bartosz DziewoƄski Date: Fri, 19 Sep 2014 15:10:40 +0000 (+0200) Subject: Allow logged-in users to view and use the login form again X-Git-Tag: 1.31.0-rc.0~13897^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=a94f11d625ea70f253e0d9620a44b447dd830b6b;p=lhc%2Fweb%2Fwiklou.git Allow logged-in users to view and use the login form again The fix for bug 15484 (d0439af8) has introduced the behavior of automatically redirecting users who view the login form when already logged in to the requested 'returnto' location. If it was not given, users were redirected to main page instead. However, that has annoyed people who often switch between several accounts and have grown accustomed to the old behavior of being able to log in while logged in. Given that there are no conflicts between these two features, let's just restore the old behavior when Special:UserLogin is visited directly (no 'returnto' location given). This reverts 5dfc57eb which removed then-dead code for showing login form to logged-in users and tweaks an if() condition. Bug: 70855 Change-Id: I7e40c13a6ca566b4d66d943c006af9edb6941ee9 --- diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index 845413e514..6de7c90d11 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -238,11 +238,19 @@ class LoginForm extends SpecialPage { } $this->setHeaders(); - // In the case where the user is already logged in, do not show the login page. - // The use case scenario for this is when a user opens a large number of tabs, is - // redirected to the login page on all of them, and then logs in on one, expecting - // all the others to work properly. - if ( $this->mType !== 'signup' && !$this->mPosted && $this->getUser()->isLoggedIn() ) { + // In the case where the user is already logged in, and was redirected to the login form from a + // page that requires login, do not show the login page. The use case scenario for this is when + // a user opens a large number of tabs, is redirected to the login page on all of them, and then + // logs in on one, expecting all the others to work properly. + // + // However, do show the form if it was visited intentionally (no 'returnto' is present). People + // who often switch between several accounts have grown accustomed to this behavior. + if ( + $this->mType !== 'signup' && + !$this->mPosted && + $this->getUser()->isLoggedIn() && + ( $this->mReturnTo !== '' || $this->mReturnToQuery !== '' ) + ) { $this->successfulLogin(); } @@ -1392,6 +1400,7 @@ class LoginForm extends SpecialPage { $template->set( 'cansecurelogin', ( $wgSecureLogin === true ) ); $template->set( 'stickhttps', (int)$this->mStickHTTPS ); $template->set( 'loggedin', $user->isLoggedIn() ); + $template->set( 'loggedinuser', $user->getName() ); if ( $this->mType == 'signup' ) { if ( !self::getCreateaccountToken() ) { diff --git a/includes/templates/Userlogin.php b/includes/templates/Userlogin.php index ad019058ec..8bba4265f0 100644 --- a/includes/templates/Userlogin.php +++ b/includes/templates/Userlogin.php @@ -37,6 +37,11 @@ class UserloginTemplate extends BaseTemplate {
+ data['loggedin'] ) { ?> +
+ getMsg( 'userlogin-loggedin' )->params( $this->data['loggedinuser'] )->parse(); ?> +
+
html( 'header' ); /* extensions such as ConfirmEdit add form HTML here */ ?>
@@ -166,9 +171,15 @@ class UserloginTemplate extends BaseTemplate {
haveData( 'createOrLoginHref' ) ) { ?> -
- msg( 'userlogin-noaccount' ); ?>msg( 'userlogin-joinproject' ); ?> -
+ data['loggedin'] ) { ?> +
+ msg( 'userlogin-createanother' ); ?> +
+ +
+ msg( 'userlogin-noaccount' ); ?>msg( 'userlogin-joinproject' ); ?> +
+ haveData( 'uselang' ) ) { ?> haveData( 'token' ) ) { ?> diff --git a/languages/i18n/en.json b/languages/i18n/en.json index d7ae546f71..ab50fa8dd8 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -407,6 +407,8 @@ "userlogin-resetpassword-link": "Forgot your password?", "helplogin-url": "https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Logging_in", "userlogin-helplink2": "Help with logging in", + "userlogin-loggedin": "You are already logged in as {{GENDER:$1|$1}}.\nUse the form below to log in as another user.", + "userlogin-createanother": "Create another account", "createacct-emailrequired": "Email address", "createacct-emailoptional": "Email address (optional)", "createacct-email-ph": "Enter your email address", diff --git a/resources/src/mediawiki.special/mediawiki.special.userlogin.login.css b/resources/src/mediawiki.special/mediawiki.special.userlogin.login.css index ee6a57c1d4..64471b2733 100644 --- a/resources/src/mediawiki.special/mediawiki.special.userlogin.login.css +++ b/resources/src/mediawiki.special/mediawiki.special.userlogin.login.css @@ -6,6 +6,10 @@ background: url(images/glyph-people-large.png) no-repeat 50%; margin: 0 auto; padding-top: 4em; +} + +#mw-createaccount-cta, +#mw-createaccount-another { font-size: 0.9em; font-weight: normal; text-align: center;