const USER_BLOCKED = 11;
const NEED_TOKEN = 12;
const WRONG_TOKEN = 13;
+ const USER_MIGRATED = 14;
/**
* Valid error and warning messages
* @param WebRequest $request
*/
public function __construct( $request = null ) {
+ global $wgUseMediaWikiUIEverywhere;
parent::__construct( 'Userlogin' );
$this->mOverrideRequest = $request;
+ // Override UseMediaWikiEverywhere to true, to force login and create form to use mw ui
+ $wgUseMediaWikiUIEverywhere = true;
}
/**
}
$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();
}
}
$u = User::newFromName( $this->mUsername );
+
+ // Give extensions a way to indicate the username has been updated,
+ // rather than telling the user the account doesn't exist.
+ if ( !wfRunHooks( 'LoginUserMigrated', array( $u, &$msg ) ) ) {
+ $this->mAbortLoginErrorMsg = $msg;
+ return self::USER_MIGRATED;
+ }
+
if ( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) {
return self::ILLEGAL;
}
$this->mainLoginForm( $this->msg( $error,
wfEscapeWikiText( $this->mUsername ) )->text() );
break;
+ case self::USER_MIGRATED:
+ $error = $this->mAbortLoginErrorMsg ?: 'login-migrated-generic';
+ $params = array();
+ if ( is_array( $error ) ) {
+ $error = array_shift( $this->mAbortLoginErrorMsg );
+ $params = $this->mAbortLoginErrorMsg;
+ }
+ $this->mainLoginForm( $this->msg( $error, $params )->text() );
+ break;
default:
throw new MWException( 'Unhandled case value' );
}
$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() ) {
}
$template->set( 'secureLoginUrl', $this->mSecureLoginUrl );
- // Use loginend-https for HTTPS requests if it's not blank, loginend otherwise
- // Ditto for signupend. New forms use neither.
+ // Use signupend-https for HTTPS requests if it's not blank, signupend otherwise
$usingHTTPS = $this->mRequest->getProtocol() == 'https';
- $loginendHTTPS = $this->msg( 'loginend-https' );
$signupendHTTPS = $this->msg( 'signupend-https' );
- if ( $usingHTTPS && !$loginendHTTPS->isBlank() ) {
- $template->set( 'loginend', $loginendHTTPS->parse() );
- } else {
- $template->set( 'loginend', $this->msg( 'loginend' )->parse() );
- }
if ( $usingHTTPS && !$signupendHTTPS->isBlank() ) {
$template->set( 'signupend', $signupendHTTPS->parse() );
} else {