3 * Holds shared logic for login and account creation pages.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @ingroup SpecialPage
24 use MediaWiki\Auth\AuthenticationRequest
;
25 use MediaWiki\Auth\AuthenticationResponse
;
26 use MediaWiki\Auth\AuthManager
;
27 use MediaWiki\Auth\Throttler
;
28 use MediaWiki\Logger\LoggerFactory
;
29 use MediaWiki\Session\SessionManager
;
32 * Holds shared logic for login and account creation pages.
34 * @ingroup SpecialPage
36 abstract class LoginSignupSpecialPage
extends AuthManagerSpecialPage
{
41 protected $mReturnToQuery;
43 protected $mStickHTTPS;
45 protected $mEntryError = '';
46 protected $mEntryErrorType = 'error';
48 protected $mLoaded = false;
49 protected $mLoadedRequest = false;
50 protected $mSecureLoginUrl;
53 protected $securityLevel;
55 /** @var bool True if the user if creating an account for someone else. Flag used for internal
56 * communication, only set at the very end. */
57 protected $proxyAccountCreation;
58 /** @var User FIXME another flag for passing data. */
59 protected $targetUser;
64 /** @var FakeAuthTemplate */
65 protected $fakeTemplate;
67 abstract protected function isSignup();
70 * @param bool $direct True if the action was successful just now; false if that happened
71 * pre-redirection (so this handler was called already)
72 * @param StatusValue|null $extraMessages
75 abstract protected function successfulAction( $direct = false, $extraMessages = null );
78 * Logs to the authmanager-stats channel.
79 * @param bool $success
80 * @param string|null $status Error message key
82 abstract protected function logAuthResult( $success, $status = null );
84 public function __construct( $name ) {
85 global $wgUseMediaWikiUIEverywhere;
86 parent
::__construct( $name );
88 // Override UseMediaWikiEverywhere to true, to force login and create form to use mw ui
89 $wgUseMediaWikiUIEverywhere = true;
92 protected function setRequest( array $data, $wasPosted = null ) {
93 parent
::setRequest( $data, $wasPosted );
94 $this->mLoadedRequest
= false;
98 * Load basic request parameters for this Special page.
101 private function loadRequestParameters( $subPage ) {
102 if ( $this->mLoadedRequest
) {
105 $this->mLoadedRequest
= true;
106 $request = $this->getRequest();
108 $this->mPosted
= $request->wasPosted();
109 $this->mIsReturn
= $subPage === 'return';
110 $this->mAction
= $request->getVal( 'action' );
111 $this->mFromHTTP
= $request->getBool( 'fromhttp', false )
112 ||
$request->getBool( 'wpFromhttp', false );
113 $this->mStickHTTPS
= ( !$this->mFromHTTP
&& $request->getProtocol() === 'https' )
114 ||
$request->getBool( 'wpForceHttps', false );
115 $this->mLanguage
= $request->getText( 'uselang' );
116 $this->mReturnTo
= $request->getVal( 'returnto', '' );
117 $this->mReturnToQuery
= $request->getVal( 'returntoquery', '' );
121 * Load data from request.
123 * @param string $subPage Subpage of Special:Userlogin
125 protected function load( $subPage ) {
126 global $wgSecureLogin;
128 $this->loadRequestParameters( $subPage );
129 if ( $this->mLoaded
) {
132 $this->mLoaded
= true;
133 $request = $this->getRequest();
135 $securityLevel = $this->getRequest()->getText( 'force' );
137 $securityLevel && AuthManager
::singleton()->securitySensitiveOperationStatus(
138 $securityLevel ) === AuthManager
::SEC_REAUTH
140 $this->securityLevel
= $securityLevel;
143 $this->loadAuth( $subPage );
145 $this->mToken
= $request->getVal( $this->getTokenName() );
147 // Show an error or warning passed on from a previous page
148 $entryError = $this->msg( $request->getVal( 'error', '' ) );
149 $entryWarning = $this->msg( $request->getVal( 'warning', '' ) );
150 // bc: provide login link as a parameter for messages where the translation
152 $loginreqlink = Linker
::linkKnown(
153 $this->getPageTitle(),
154 $this->msg( 'loginreqlink' )->escaped(),
157 'returnto' => $this->mReturnTo
,
158 'returntoquery' => $this->mReturnToQuery
,
159 'uselang' => $this->mLanguage
,
160 'fromhttp' => $wgSecureLogin && $this->mFromHTTP ?
'1' : null,
164 // Only show valid error or warning messages.
165 if ( $entryError->exists()
166 && in_array( $entryError->getKey(), LoginHelper
::getValidErrorMessages(), true )
168 $this->mEntryErrorType
= 'error';
169 $this->mEntryError
= $entryError->rawParams( $loginreqlink )->parse();
171 } elseif ( $entryWarning->exists()
172 && in_array( $entryWarning->getKey(), LoginHelper
::getValidErrorMessages(), true )
174 $this->mEntryErrorType
= 'warning';
175 $this->mEntryError
= $entryWarning->rawParams( $loginreqlink )->parse();
178 # 1. When switching accounts, it sucks to get automatically logged out
179 # 2. Do not return to PasswordReset after a successful password change
180 # but goto Wiki start page (Main_Page) instead ( bug 33997 )
181 $returnToTitle = Title
::newFromText( $this->mReturnTo
);
182 if ( is_object( $returnToTitle )
183 && ( $returnToTitle->isSpecial( 'Userlogout' )
184 ||
$returnToTitle->isSpecial( 'PasswordReset' ) )
186 $this->mReturnTo
= '';
187 $this->mReturnToQuery
= '';
191 protected function getPreservedParams( $withToken = false ) {
192 global $wgSecureLogin;
194 $params = parent
::getPreservedParams( $withToken );
196 'returnto' => $this->mReturnTo ?
: null,
197 'returntoquery' => $this->mReturnToQuery ?
: null,
199 if ( $wgSecureLogin && !$this->isSignup() ) {
200 $params['fromhttp'] = $this->mFromHTTP ?
'1' : null;
205 protected function beforeExecute( $subPage ) {
206 // finish initializing the class before processing the request - T135924
207 $this->loadRequestParameters( $subPage );
208 return parent
::beforeExecute( $subPage );
212 * @param string|null $subPage
214 public function execute( $subPage ) {
215 $authManager = AuthManager
::singleton();
216 $session = SessionManager
::getGlobalSession();
218 // Session data is used for various things in the authentication process, so we must make
219 // sure a session cookie or some equivalent mechanism is set.
222 $this->load( $subPage );
224 $this->checkPermissions();
226 // Make sure the system configuration allows log in / sign up
227 if ( !$this->isSignup() && !$authManager->canAuthenticateNow() ) {
228 if ( !$session->canSetUser() ) {
229 throw new ErrorPageError( 'cannotloginnow-title', 'cannotloginnow-text', [
230 $session->getProvider()->describe( RequestContext
::getMain()->getLanguage() )
233 throw new ErrorPageError( 'cannotlogin-title', 'cannotlogin-text' );
234 } elseif ( $this->isSignup() && !$authManager->canCreateAccounts() ) {
235 throw new ErrorPageError( 'cannotcreateaccount-title', 'cannotcreateaccount-text' );
239 * In the case where the user is already logged in, and was redirected to
240 * the login form from a page that requires login, do not show the login
241 * page. The use case scenario for this is when a user opens a large number
242 * of tabs, is redirected to the login page on all of them, and then logs
243 * in on one, expecting all the others to work properly.
245 * However, do show the form if it was visited intentionally (no 'returnto'
246 * is present). People who often switch between several accounts have grown
247 * accustomed to this behavior.
249 * Also make an exception when force=<level> is set in the URL, which means the user must
250 * reauthenticate for security reasons.
252 if ( !$this->isSignup() && !$this->mPosted
&& !$this->securityLevel
&&
253 ( $this->mReturnTo
!== '' ||
$this->mReturnToQuery
!== '' ) &&
254 $this->getUser()->isLoggedIn()
256 $this->successfulAction();
259 // If logging in and not on HTTPS, either redirect to it or offer a link.
260 global $wgSecureLogin;
261 if ( $this->getRequest()->getProtocol() !== 'https' ) {
262 $title = $this->getFullTitle();
263 $query = $this->getPreservedParams( false ) +
[
265 ( $this->mEntryErrorType
=== 'error' ?
'error'
266 : 'warning' ) => $this->mEntryError
,
267 ] +
$this->getRequest()->getQueryValues();
268 $url = $title->getFullURL( $query, false, PROTO_HTTPS
);
269 if ( $wgSecureLogin && !$this->mFromHTTP
&&
270 wfCanIPUseHTTPS( $this->getRequest()->getIP() )
272 // Avoid infinite redirect
273 $url = wfAppendQuery( $url, 'fromhttp=1' );
274 $this->getOutput()->redirect( $url );
275 // Since we only do this redir to change proto, always vary
276 $this->getOutput()->addVaryHeader( 'X-Forwarded-Proto' );
280 // A wiki without HTTPS login support should set $wgServer to
281 // http://somehost, in which case the secure URL generated
282 // above won't actually start with https://
283 if ( substr( $url, 0, 8 ) === 'https://' ) {
284 $this->mSecureLoginUrl
= $url;
289 if ( !$this->isActionAllowed( $this->authAction
) ) {
290 // FIXME how do we explain this to the user? can we handle session loss better?
291 // messages used: authpage-cannot-login, authpage-cannot-login-continue,
292 // authpage-cannot-create, authpage-cannot-create-continue
293 $this->mainLoginForm( [], 'authpage-cannot-' . $this->authAction
);
297 $status = $this->trySubmit();
299 if ( !$status ||
!$status->isGood() ) {
300 $this->mainLoginForm( $this->authRequests
, $status ?
$status->getMessage() : '', 'error' );
304 /** @var AuthenticationResponse $response */
305 $response = $status->getValue();
307 $returnToUrl = $this->getPageTitle( 'return' )
308 ->getFullURL( $this->getPreservedParams( true ), false, PROTO_HTTPS
);
309 switch ( $response->status
) {
310 case AuthenticationResponse
::PASS
:
311 $this->logAuthResult( true );
312 $this->proxyAccountCreation
= $this->isSignup() && !$this->getUser()->isAnon();
313 $this->targetUser
= User
::newFromName( $response->username
);
316 !$this->proxyAccountCreation
317 && $response->loginRequest
318 && $authManager->canAuthenticateNow()
320 // successful registration; log the user in instantly
321 $response2 = $authManager->beginAuthentication( [ $response->loginRequest
],
323 if ( $response2->status
!== AuthenticationResponse
::PASS
) {
324 LoggerFactory
::getInstance( 'login' )
325 ->error( 'Could not log in after account creation' );
326 $this->successfulAction( true, Status
::newFatal( 'createacct-loginerror' ) );
331 if ( !$this->proxyAccountCreation
) {
332 // Ensure that the context user is the same as the session user.
333 $this->setSessionUserForCurrentRequest();
336 $this->successfulAction( true );
338 case AuthenticationResponse
::FAIL
:
340 case AuthenticationResponse
::RESTART
:
341 unset( $this->authForm
);
342 if ( $response->status
=== AuthenticationResponse
::FAIL
) {
343 $action = $this->getDefaultAction( $subPage );
344 $messageType = 'error';
346 $action = $this->getContinueAction( $this->authAction
);
347 $messageType = 'warning';
349 $this->logAuthResult( false, $response->message ?
$response->message
->getKey() : '-' );
350 $this->loadAuth( $subPage, $action, true );
351 $this->mainLoginForm( $this->authRequests
, $response->message
, $messageType );
353 case AuthenticationResponse
::REDIRECT
:
354 unset( $this->authForm
);
355 $this->getOutput()->redirect( $response->redirectTarget
);
357 case AuthenticationResponse
::UI
:
358 unset( $this->authForm
);
359 $this->authAction
= $this->isSignup() ? AuthManager
::ACTION_CREATE_CONTINUE
360 : AuthManager
::ACTION_LOGIN_CONTINUE
;
361 $this->authRequests
= $response->neededRequests
;
362 $this->mainLoginForm( $response->neededRequests
, $response->message
, $response->messageType
);
365 throw new LogicException( 'invalid AuthenticationResponse' );
370 * Show the success page.
372 * @param string $type Condition of return to; see `executeReturnTo`
373 * @param string|Message $title Page's title
374 * @param string $msgname
375 * @param string $injected_html
376 * @param StatusValue|null $extraMessages
378 protected function showSuccessPage(
379 $type, $title, $msgname, $injected_html, $extraMessages
381 $out = $this->getOutput();
382 $out->setPageTitle( $title );
384 $out->addWikiMsg( $msgname, wfEscapeWikiText( $this->getUser()->getName() ) );
386 if ( $extraMessages ) {
387 $extraMessages = Status
::wrap( $extraMessages );
388 $out->addWikiText( $extraMessages->getWikiText() );
391 $out->addHTML( $injected_html );
393 $helper = new LoginHelper( $this->getContext() );
394 $helper->showReturnToPage( $type, $this->mReturnTo
, $this->mReturnToQuery
, $this->mStickHTTPS
);
398 * Add a "return to" link or redirect to it.
399 * Extensions can use this to reuse the "return to" logic after
400 * inject steps (such as redirection) into the login process.
402 * @param string $type One of the following:
403 * - error: display a return to link ignoring $wgRedirectOnLogin
404 * - signup: display a return to link using $wgRedirectOnLogin if needed
405 * - success: display a return to link using $wgRedirectOnLogin if needed
406 * - successredirect: send an HTTP redirect using $wgRedirectOnLogin if needed
407 * @param string $returnTo
408 * @param array|string $returnToQuery
409 * @param bool $stickHTTPS Keep redirect link on HTTPS
412 public function showReturnToPage(
413 $type, $returnTo = '', $returnToQuery = '', $stickHTTPS = false
415 $helper = new LoginHelper( $this->getContext() );
416 $helper->showReturnToPage( $type, $returnTo, $returnToQuery, $stickHTTPS );
420 * Replace some globals to make sure the fact that the user has just been logged in is
421 * reflected in the current request.
424 protected function setSessionUserForCurrentRequest() {
425 global $wgUser, $wgLang;
427 $context = RequestContext
::getMain();
428 $localContext = $this->getContext();
429 if ( $context !== $localContext ) {
430 // remove AuthManagerSpecialPage context hack
431 $this->setContext( $context );
434 $user = $context->getRequest()->getSession()->getUser();
437 $context->setUser( $user );
439 $code = $this->getRequest()->getVal( 'uselang', $user->getOption( 'language' ) );
440 $userLang = Language
::factory( $code );
442 $context->setLanguage( $userLang );
446 * @param AuthenticationRequest[] $requests A list of AuthorizationRequest objects,
447 * used to generate the form fields. An empty array means a fatal error
448 * (authentication cannot continue).
449 * @param string|Message $msg
450 * @param string $msgtype
451 * @throws ErrorPageError
454 * @throws MWException
455 * @throws PermissionsError
456 * @throws ReadOnlyError
459 protected function mainLoginForm( array $requests, $msg = '', $msgtype = 'error' ) {
460 $titleObj = $this->getPageTitle();
461 $user = $this->getUser();
462 $out = $this->getOutput();
464 // FIXME how to handle empty $requests - restart, or no form, just an error message?
465 // no form would be better for no session type errors, restart is better when can* fails.
467 $this->authAction
= $this->getDefaultAction( $this->subPage
);
468 $this->authForm
= null;
469 $requests = AuthManager
::singleton()->getAuthenticationRequests( $this->authAction
, $user );
472 // Generic styles and scripts for both login and signup form
473 $out->addModuleStyles( [
475 'mediawiki.ui.button',
476 'mediawiki.ui.checkbox',
477 'mediawiki.ui.input',
478 'mediawiki.special.userlogin.common.styles'
480 if ( $this->isSignup() ) {
481 // XXX hack pending RL or JS parse() support for complex content messages T27349
482 $out->addJsConfigVars( 'wgCreateacctImgcaptchaHelp',
483 $this->msg( 'createacct-imgcaptcha-help' )->parse() );
485 // Additional styles and scripts for signup form
487 'mediawiki.special.userlogin.signup.js'
489 $out->addModuleStyles( [
490 'mediawiki.special.userlogin.signup.styles'
493 // Additional styles for login form
494 $out->addModuleStyles( [
495 'mediawiki.special.userlogin.login.styles'
498 $out->disallowUserJs(); // just in case...
500 $form = $this->getAuthForm( $requests, $this->authAction
, $msg, $msgtype );
501 $form->prepareForm();
503 $submitStatus = Status
::newGood();
504 if ( $msg && $msgtype === 'warning' ) {
505 $submitStatus->warning( $msg );
506 } elseif ( $msg && $msgtype === 'error' ) {
507 $submitStatus->fatal( $msg );
510 // warning header for non-standard workflows (e.g. security reauthentication)
511 if ( !$this->isSignup() && $this->getUser()->isLoggedIn() ) {
512 $reauthMessage = $this->securityLevel ?
'userlogin-reauth' : 'userlogin-loggedin';
513 $submitStatus->warning( $reauthMessage, $this->getUser()->getName() );
516 $formHtml = $form->getHTML( $submitStatus );
518 $out->addHTML( $this->getPageHtml( $formHtml ) );
522 * Add page elements which are outside the form.
523 * FIXME this should probably be a template, but use a sane language (handlebars?)
524 * @param string $formHtml
527 protected function getPageHtml( $formHtml ) {
528 global $wgLoginLanguageSelector;
530 $loginPrompt = $this->isSignup() ?
'' : Html
::rawElement( 'div',
531 [ 'id' => 'userloginprompt' ], $this->msg( 'loginprompt' )->parseAsBlock() );
532 $languageLinks = $wgLoginLanguageSelector ?
$this->makeLanguageSelector() : '';
533 $signupStartMsg = $this->msg( 'signupstart' );
534 $signupStart = ( $this->isSignup() && !$signupStartMsg->isDisabled() )
535 ? Html
::rawElement( 'div', [ 'id' => 'signupstart' ], $signupStartMsg->parseAsBlock() ) : '';
536 if ( $languageLinks ) {
537 $languageLinks = Html
::rawElement( 'div', [ 'id' => 'languagelinks' ],
538 Html
::rawElement( 'p', [], $languageLinks )
542 $benefitsContainer = '';
543 if ( $this->isSignup() && $this->showExtraInformation() ) {
545 // createacct-benefit-icon1 createacct-benefit-head1 createacct-benefit-body1
546 // createacct-benefit-icon2 createacct-benefit-head2 createacct-benefit-body2
547 // createacct-benefit-icon3 createacct-benefit-head3 createacct-benefit-body3
550 for ( $benefitIdx = 1; $benefitIdx <= $benefitCount; $benefitIdx++
) {
551 $headUnescaped = $this->msg( "createacct-benefit-head$benefitIdx" )->text();
552 $iconClass = $this->msg( "createacct-benefit-icon$benefitIdx" )->escaped();
553 $benefitList .= Html
::rawElement( 'div', [ 'class' => "mw-number-text $iconClass" ],
554 Html
::rawElement( 'h3', [],
555 $this->msg( "createacct-benefit-head$benefitIdx" )->escaped()
557 . Html
::rawElement( 'p', [],
558 $this->msg( "createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped()
562 $benefitsContainer = Html
::rawElement( 'div', [ 'class' => 'mw-createacct-benefits-container' ],
563 Html
::rawElement( 'h2', [], $this->msg( 'createacct-benefit-heading' )->escaped() )
564 . Html
::rawElement( 'div', [ 'class' => 'mw-createacct-benefits-list' ],
570 $html = Html
::rawElement( 'div', [ 'class' => 'mw-ui-container' ],
574 . Html
::rawElement( 'div', [ 'id' => 'userloginForm' ],
584 * Generates a form from the given request.
585 * @param AuthenticationRequest[] $requests
586 * @param string $action AuthManager action name
587 * @param string|Message $msg
588 * @param string $msgType
591 protected function getAuthForm( array $requests, $action, $msg = '', $msgType = 'error' ) {
592 global $wgSecureLogin, $wgLoginLanguageSelector;
593 // FIXME merge this with parent
595 if ( isset( $this->authForm
) ) {
596 return $this->authForm
;
599 $usingHTTPS = $this->getRequest()->getProtocol() === 'https';
601 // get basic form description from the auth logic
602 $fieldInfo = AuthenticationRequest
::mergeFieldInfo( $requests );
603 $fakeTemplate = $this->getFakeTemplate( $msg, $msgType );
604 $this->fakeTemplate
= $fakeTemplate; // FIXME there should be a saner way to pass this to the hook
605 // this will call onAuthChangeFormFields()
606 $formDescriptor = static::fieldInfoToFormDescriptor( $requests, $fieldInfo, $this->authAction
);
607 $this->postProcessFormDescriptor( $formDescriptor, $requests );
609 $context = $this->getContext();
610 if ( $context->getRequest() !== $this->getRequest() ) {
611 // We have overridden the request, need to make sure the form uses that too.
612 $context = new DerivativeContext( $this->getContext() );
613 $context->setRequest( $this->getRequest() );
615 $form = HTMLForm
::factory( 'vform', $formDescriptor, $context );
617 $form->addHiddenField( 'authAction', $this->authAction
);
618 if ( $wgLoginLanguageSelector ) {
619 $form->addHiddenField( 'uselang', $this->mLanguage
);
621 $form->addHiddenField( 'force', $this->securityLevel
);
622 $form->addHiddenField( $this->getTokenName(), $this->getToken()->toString() );
623 if ( $wgSecureLogin ) {
624 // If using HTTPS coming from HTTP, then the 'fromhttp' parameter must be preserved
625 if ( !$this->isSignup() ) {
626 $form->addHiddenField( 'wpForceHttps', (int)$this->mStickHTTPS
);
627 $form->addHiddenField( 'wpFromhttp', $usingHTTPS );
631 // set properties of the form itself
632 $form->setAction( $this->getPageTitle()->getLocalURL( $this->getReturnToQueryStringFragment() ) );
633 $form->setName( 'userlogin' . ( $this->isSignup() ?
'2' : '' ) );
634 if ( $this->isSignup() ) {
635 $form->setId( 'userlogin2' );
638 $form->suppressDefaultSubmit();
640 $this->authForm
= $form;
646 * Temporary B/C method to handle extensions using the UserLoginForm/UserCreateForm hooks.
647 * @param string|Message $msg
648 * @param string $msgType
649 * @return FakeAuthTemplate
651 protected function getFakeTemplate( $msg, $msgType ) {
652 global $wgAuth, $wgEnableEmail, $wgHiddenPrefs, $wgEmailConfirmToEdit, $wgEnableUserEmail,
653 $wgSecureLogin, $wgLoginLanguageSelector, $wgPasswordResetRoutes;
655 // make a best effort to get the value of fields which used to be fixed in the old login
656 // template but now might or might not exist depending on what providers are used
657 $request = $this->getRequest();
659 'mUsername' => $request->getText( 'wpName' ),
660 'mPassword' => $request->getText( 'wpPassword' ),
661 'mRetype' => $request->getText( 'wpRetype' ),
662 'mEmail' => $request->getText( 'wpEmail' ),
663 'mRealName' => $request->getText( 'wpRealName' ),
664 'mDomain' => $request->getText( 'wpDomain' ),
665 'mReason' => $request->getText( 'wpReason' ),
666 'mRemember' => $request->getCheck( 'wpRemember' ),
669 // Preserves a bunch of logic from the old code that was rewritten in getAuthForm().
670 // There is no code reuse to make this easier to remove .
671 // If an extension tries to change any of these values, they are out of luck - we only
672 // actually use the domain/usedomain/domainnames, extraInput and extrafields keys.
674 $titleObj = $this->getPageTitle();
675 $user = $this->getUser();
676 $template = new FakeAuthTemplate();
678 // Pre-fill username (if not creating an account, bug 44775).
679 if ( $data->mUsername
== '' && $this->isSignup() ) {
680 if ( $user->isLoggedIn() ) {
681 $data->mUsername
= $user->getName();
683 $data->mUsername
= $this->getRequest()->getSession()->suggestLoginUsername();
687 if ( $this->isSignup() ) {
688 // Must match number of benefits defined in messages
689 $template->set( 'benefitCount', 3 );
691 $q = 'action=submitlogin&type=signup';
692 $linkq = 'type=login';
694 $q = 'action=submitlogin&type=login';
695 $linkq = 'type=signup';
698 if ( $this->mReturnTo
!== '' ) {
699 $returnto = '&returnto=' . wfUrlencode( $this->mReturnTo
);
700 if ( $this->mReturnToQuery
!== '' ) {
701 $returnto .= '&returntoquery=' .
702 wfUrlencode( $this->mReturnToQuery
);
708 # Don't show a "create account" link if the user can't.
709 if ( $this->showCreateAccountLink() ) {
710 # Pass any language selection on to the mode switch link
711 if ( $wgLoginLanguageSelector && $this->mLanguage
) {
712 $linkq .= '&uselang=' . $this->mLanguage
;
714 // Supply URL, login template creates the button.
715 $template->set( 'createOrLoginHref', $titleObj->getLocalURL( $linkq ) );
717 $template->set( 'link', '' );
720 $resetLink = $this->isSignup()
722 : is_array( $wgPasswordResetRoutes )
723 && in_array( true, array_values( $wgPasswordResetRoutes ), true );
725 $template->set( 'header', '' );
726 $template->set( 'formheader', '' );
727 $template->set( 'skin', $this->getSkin() );
729 $template->set( 'name', $data->mUsername
);
730 $template->set( 'password', $data->mPassword
);
731 $template->set( 'retype', $data->mRetype
);
732 $template->set( 'createemailset', false ); // no easy way to get that from AuthManager
733 $template->set( 'email', $data->mEmail
);
734 $template->set( 'realname', $data->mRealName
);
735 $template->set( 'domain', $data->mDomain
);
736 $template->set( 'reason', $data->mReason
);
737 $template->set( 'remember', $data->mRemember
);
739 $template->set( 'action', $titleObj->getLocalURL( $q ) );
740 $template->set( 'message', $msg );
741 $template->set( 'messagetype', $msgType );
742 $template->set( 'createemail', $wgEnableEmail && $user->isLoggedIn() );
743 $template->set( 'userealname', !in_array( 'realname', $wgHiddenPrefs, true ) );
744 $template->set( 'useemail', $wgEnableEmail );
745 $template->set( 'emailrequired', $wgEmailConfirmToEdit );
746 $template->set( 'emailothers', $wgEnableUserEmail );
747 $template->set( 'canreset', $wgAuth->allowPasswordChange() );
748 $template->set( 'resetlink', $resetLink );
749 $template->set( 'canremember', $request->getSession()->getProvider()
750 ->getRememberUserDuration() !== null );
751 $template->set( 'usereason', $user->isLoggedIn() );
752 $template->set( 'cansecurelogin', ( $wgSecureLogin ) );
753 $template->set( 'stickhttps', (int)$this->mStickHTTPS
);
754 $template->set( 'loggedin', $user->isLoggedIn() );
755 $template->set( 'loggedinuser', $user->getName() );
756 $template->set( 'token', $this->getToken()->toString() );
758 $action = $this->isSignup() ?
'signup' : 'login';
759 $wgAuth->modifyUITemplate( $template, $action );
761 $oldTemplate = $template;
762 $hookName = $this->isSignup() ?
'UserCreateForm' : 'UserLoginForm';
763 Hooks
::run( $hookName, [ &$template ] );
764 if ( $oldTemplate !== $template ) {
765 wfDeprecated( "reference in $hookName hook", '1.27' );
772 public function onAuthChangeFormFields(
773 array $requests, array $fieldInfo, array &$formDescriptor, $action
775 $coreFieldDescriptors = $this->getFieldDefinitions( $this->fakeTemplate
);
776 $specialFields = array_merge( [ 'extraInput' ],
777 array_keys( $this->fakeTemplate
->getExtraInputDefinitions() ) );
779 // keep the ordering from getCoreFieldDescriptors() where there is no explicit weight
780 foreach ( $coreFieldDescriptors as $fieldName => $coreField ) {
781 $requestField = isset( $formDescriptor[$fieldName] ) ?
782 $formDescriptor[$fieldName] : [];
784 // remove everything that is not in the fieldinfo, is not marked as a supplemental field
785 // to something in the fieldinfo, is not B/C for the pre-AuthManager templates,
786 // and is not an info field or a submit button
788 !isset( $fieldInfo[$fieldName] )
790 !isset( $coreField['baseField'] )
791 ||
!isset( $fieldInfo[$coreField['baseField']] )
793 && !in_array( $fieldName, $specialFields, true )
795 !isset( $coreField['type'] )
796 ||
!in_array( $coreField['type'], [ 'submit', 'info' ], true )
799 $coreFieldDescriptors[$fieldName] = null;
803 // core message labels should always take priority
805 isset( $coreField['label'] )
806 ||
isset( $coreField['label-message'] )
807 ||
isset( $coreField['label-raw'] )
809 unset( $requestField['label'], $requestField['label-message'], $coreField['label-raw'] );
812 $coreFieldDescriptors[$fieldName] +
= $requestField;
815 $formDescriptor = array_filter( $coreFieldDescriptors +
$formDescriptor );
820 * Show extra information such as password recovery information, link from login to signup,
821 * CTA etc? Such information should only be shown on the "landing page", ie. when the user
822 * is at the first step of the authentication process.
825 protected function showExtraInformation() {
826 return $this->authAction
!== $this->getContinueAction( $this->authAction
)
827 && !$this->securityLevel
;
831 * Create a HTMLForm descriptor for the core login fields.
832 * @param FakeAuthTemplate $template B/C data (not used but needed by getBCFieldDefinitions)
835 protected function getFieldDefinitions( $template ) {
836 global $wgEmailConfirmToEdit, $wgLoginLanguageSelector;
838 $isLoggedIn = $this->getUser()->isLoggedIn();
839 $continuePart = $this->isContinued() ?
'continue-' : '';
840 $anotherPart = $isLoggedIn ?
'another-' : '';
841 $expiration = $this->getRequest()->getSession()->getProvider()->getRememberUserDuration();
842 $expirationDays = ceil( $expiration / ( 3600 * 24 ) );
843 $secureLoginLink = '';
844 if ( $this->mSecureLoginUrl
) {
845 $secureLoginLink = Html
::element( 'a', [
846 'href' => $this->mSecureLoginUrl
,
847 'class' => 'mw-ui-flush-right mw-secure',
848 ], $this->msg( 'userlogin-signwithsecure' )->text() );
850 $usernameHelpLink = '';
851 if ( !$this->msg( 'createacct-helpusername' )->isDisabled() ) {
852 $usernameHelpLink = Html
::rawElement( 'span', [
853 'class' => 'mw-ui-flush-right',
854 ], $this->msg( 'createacct-helpusername' )->parse() );
857 if ( $this->isSignup() ) {
858 $fieldDefinitions = [
860 // used by the mediawiki.special.userlogin.signup.js module for error display
861 // FIXME merge this with HTMLForm's normal status (error) area
864 'default' => Html
::element( 'div', [ 'id' => 'mw-createacct-status-area' ] ),
868 'label-raw' => $this->msg( 'userlogin-yourname' )->escaped() . $usernameHelpLink,
870 'placeholder-message' => $isLoggedIn ?
'createacct-another-username-ph'
871 : 'userlogin-yourname-ph',
874 // create account without providing password, a temporary one will be mailed
876 'label-message' => 'createaccountmail',
877 'name' => 'wpCreateaccountMail',
878 'id' => 'wpCreateaccountMail',
881 'id' => 'wpPassword2',
882 'placeholder-message' => 'createacct-yourpassword-ph',
883 'hide-if' => [ '===', 'wpCreateaccountMail', '1' ],
887 'baseField' => 'password',
888 'type' => 'password',
889 'label-message' => 'createacct-yourpasswordagain',
891 'cssclass' => 'loginPassword',
893 'validation-callback' => function ( $value, $alldata ) {
894 if ( empty( $alldata['mailpassword'] ) && !empty( $alldata['password'] ) ) {
896 return $this->msg( 'htmlform-required' );
897 } elseif ( $value !== $alldata['password'] ) {
898 return $this->msg( 'badretype' );
903 'hide-if' => [ '===', 'wpCreateaccountMail', '1' ],
904 'placeholder-message' => 'createacct-yourpasswordagain-ph',
908 'label-message' => $wgEmailConfirmToEdit ?
'createacct-emailrequired'
909 : 'createacct-emailoptional',
911 'cssclass' => 'loginText',
913 // FIXME will break non-standard providers
914 'required' => $wgEmailConfirmToEdit,
915 'validation-callback' => function ( $value, $alldata ) {
916 global $wgEmailConfirmToEdit;
918 // AuthManager will check most of these, but that will make the auth
919 // session fail and this won't, so nicer to do it this way
920 if ( !$value && $wgEmailConfirmToEdit ) {
921 // no point in allowing registration without email when email is
923 return $this->msg( 'noemailtitle' );
924 } elseif ( !$value && !empty( $alldata['mailpassword'] ) ) {
925 // cannot send password via email when there is no email address
926 return $this->msg( 'noemailcreate' );
927 } elseif ( $value && !Sanitizer
::validateEmail( $value ) ) {
928 return $this->msg( 'invalidemailaddress' );
932 'placeholder-message' => 'createacct-' . $anotherPart . 'email-ph',
936 'help-message' => $isLoggedIn ?
'createacct-another-realname-tip'
937 : 'prefs-help-realname',
938 'label-message' => 'createacct-realname',
939 'cssclass' => 'loginText',
941 'id' => 'wpRealName',
944 // comment for the user creation log
946 'label-message' => 'createacct-reason',
947 'cssclass' => 'loginText',
950 'placeholder-message' => 'createacct-reason-ph',
952 'extrainput' => [], // placeholder for fields coming from the template
956 'default' => $this->msg( 'createacct-' . $anotherPart . $continuePart .
958 'name' => 'wpCreateaccount',
959 'id' => 'wpCreateaccount',
964 $fieldDefinitions = [
966 'label-raw' => $this->msg( 'userlogin-yourname' )->escaped() . $secureLoginLink,
968 'placeholder-message' => 'userlogin-yourname-ph',
971 'id' => 'wpPassword1',
972 'placeholder-message' => 'userlogin-yourpassword-ph',
977 // option for saving the user token to a cookie
979 'name' => 'wpRemember',
980 'label-message' => $this->msg( 'userlogin-remembermypassword' )
981 ->numParams( $expirationDays ),
982 'id' => 'wpRemember',
987 'default' => $this->msg( 'pt-login-' . $continuePart . 'button' )->text(),
988 'id' => 'wpLoginAttempt',
994 'cssclass' => 'mw-form-related-link-container mw-userlogin-help',
995 // 'id' => 'mw-userlogin-help', // FIXME HTMLInfoField ignores this
997 'default' => Html
::element( 'a', [
998 'href' => Skin
::makeInternalOrExternalUrl( wfMessage( 'helplogin-url' )
999 ->inContentLanguage()
1001 ], $this->msg( 'userlogin-helplink2' )->text() ),
1004 // button for ResetPasswordSecondaryAuthenticationProvider
1012 $fieldDefinitions['username'] +
= [
1015 'cssclass' => 'loginText',
1017 // 'required' => true,
1019 $fieldDefinitions['password'] +
= [
1020 'type' => 'password',
1021 // 'label-message' => 'userlogin-yourpassword', // would override the changepassword label
1022 'name' => 'wpPassword',
1023 'cssclass' => 'loginPassword',
1025 // 'required' => true,
1028 if ( $template->get( 'header' ) ||
$template->get( 'formheader' ) ) {
1029 // B/C for old extensions that haven't been converted to AuthManager (or have been
1030 // but somebody is using the old version) and still use templates via the
1031 // UserCreateForm/UserLoginForm hook.
1032 // 'header' used by ConfirmEdit, CondfirmAccount, Persona, WikimediaIncubator, SemanticSignup
1033 // 'formheader' used by MobileFrontend
1034 $fieldDefinitions['header'] = [
1037 'default' => $template->get( 'header' ) ?
: $template->get( 'formheader' ),
1041 if ( $this->mEntryError
) {
1042 $fieldDefinitions['entryError'] = [
1044 'default' => Html
::rawElement( 'div', [ 'class' => $this->mEntryErrorType
. 'box', ],
1045 $this->mEntryError
),
1051 if ( !$this->showExtraInformation() ) {
1052 unset( $fieldDefinitions['linkcontainer'], $fieldDefinitions['signupend'] );
1054 if ( $this->isSignup() && $this->showExtraInformation() ) {
1055 // blank signup footer for site customization
1056 // uses signupend-https for HTTPS requests if it's not blank, signupend otherwise
1057 $signupendMsg = $this->msg( 'signupend' );
1058 $signupendHttpsMsg = $this->msg( 'signupend-https' );
1059 if ( !$signupendMsg->isDisabled() ) {
1060 $usingHTTPS = $this->getRequest()->getProtocol() === 'https';
1061 $signupendText = ( $usingHTTPS && !$signupendHttpsMsg->isBlank() )
1062 ?
$signupendHttpsMsg ->parse() : $signupendMsg->parse();
1063 $fieldDefinitions['signupend'] = [
1066 'default' => Html
::rawElement( 'div', [ 'id' => 'signupend' ], $signupendText ),
1071 if ( !$this->isSignup() && $this->showExtraInformation() ) {
1072 $passwordReset = new PasswordReset( $this->getConfig(), AuthManager
::singleton() );
1073 if ( $passwordReset->isAllowed( $this->getUser() )->isGood() ) {
1074 $fieldDefinitions['passwordReset'] = [
1077 'cssclass' => 'mw-form-related-link-container',
1078 'default' => Linker
::link(
1079 SpecialPage
::getTitleFor( 'PasswordReset' ),
1080 $this->msg( 'userlogin-resetpassword-link' )->escaped()
1086 // Don't show a "create account" link if the user can't.
1087 if ( $this->showCreateAccountLink() ) {
1088 // link to the other action
1089 $linkTitle = $this->getTitleFor( $this->isSignup() ?
'Userlogin' :'CreateAccount' );
1090 $linkq = $this->getReturnToQueryStringFragment();
1091 // Pass any language selection on to the mode switch link
1092 if ( $wgLoginLanguageSelector && $this->mLanguage
) {
1093 $linkq .= '&uselang=' . $this->mLanguage
;
1095 $loggedIn = $this->getUser()->isLoggedIn();
1097 $fieldDefinitions['createOrLogin'] = [
1100 'linkQuery' => $linkq,
1101 'default' => function ( $params ) use ( $loggedIn, $linkTitle ) {
1102 return Html
::rawElement( 'div',
1103 [ 'id' => 'mw-createaccount' . ( !$loggedIn ?
'-cta' : '' ),
1104 'class' => ( $loggedIn ?
'mw-form-related-link-container' : 'mw-ui-vform-field' ) ],
1105 ( $loggedIn ?
'' : $this->msg( 'userlogin-noaccount' )->escaped() )
1106 . Html
::element( 'a',
1108 'id' => 'mw-createaccount-join' . ( $loggedIn ?
'-loggedin' : '' ),
1109 'href' => $linkTitle->getLocalURL( $params['linkQuery'] ),
1110 'class' => ( $loggedIn ?
'' : 'mw-ui-button' ),
1114 $loggedIn ?
'userlogin-createanother' : 'userlogin-joinproject'
1124 $fieldDefinitions = $this->getBCFieldDefinitions( $fieldDefinitions, $template );
1125 $fieldDefinitions = array_filter( $fieldDefinitions );
1127 return $fieldDefinitions;
1131 * Adds fields provided via the deprecated UserLoginForm / UserCreateForm hooks
1132 * @param $fieldDefinitions array
1133 * @param FakeAuthTemplate $template
1136 protected function getBCFieldDefinitions( $fieldDefinitions, $template ) {
1137 if ( $template->get( 'usedomain', false ) ) {
1138 // TODO probably should be translated to the new domain notation in AuthManager
1139 $fieldDefinitions['domain'] = [
1141 'label-message' => 'yourdomainname',
1142 'options' => array_combine( $template->get( 'domainnames', [] ),
1143 $template->get( 'domainnames', [] ) ),
1144 'default' => $template->get( 'domain', '' ),
1145 'name' => 'wpDomain',
1146 // FIXME id => 'mw-user-domain-section' on the parent div
1150 // poor man's associative array_splice
1151 $extraInputPos = array_search( 'extrainput', array_keys( $fieldDefinitions ), true );
1152 $fieldDefinitions = array_slice( $fieldDefinitions, 0, $extraInputPos, true )
1153 +
$template->getExtraInputDefinitions()
1154 +
array_slice( $fieldDefinitions, $extraInputPos +
1, null, true );
1156 return $fieldDefinitions;
1160 * Check if a session cookie is present.
1162 * This will not pick up a cookie set during _this_ request, but is meant
1163 * to ensure that the client is returning the cookie which was set on a
1164 * previous pass through the system.
1168 protected function hasSessionCookie() {
1169 global $wgDisableCookieCheck, $wgInitialSessionId;
1171 return $wgDisableCookieCheck ||
(
1172 $wgInitialSessionId &&
1173 $this->getRequest()->getSession()->getId() === (string)$wgInitialSessionId
1178 * Returns a string that can be appended to the URL (without encoding) to preserve the
1179 * return target. Does not include leading '?'/'&'.
1181 protected function getReturnToQueryStringFragment() {
1183 if ( $this->mReturnTo
!== '' ) {
1184 $returnto = 'returnto=' . wfUrlencode( $this->mReturnTo
);
1185 if ( $this->mReturnToQuery
!== '' ) {
1186 $returnto .= '&returntoquery=' . wfUrlencode( $this->mReturnToQuery
);
1193 * Whether the login/create account form should display a link to the
1194 * other form (in addition to whatever the skin provides).
1197 private function showCreateAccountLink() {
1198 if ( $this->isSignup() ) {
1200 } elseif ( $this->getUser()->isAllowed( 'createaccount' ) ) {
1207 protected function getTokenName() {
1208 return $this->isSignup() ?
'wpCreateaccountToken' : 'wpLoginToken';
1212 * Produce a bar of links which allow the user to select another language
1213 * during login/registration but retain "returnto"
1217 protected function makeLanguageSelector() {
1218 $msg = $this->msg( 'loginlanguagelinks' )->inContentLanguage();
1219 if ( $msg->isBlank() ) {
1222 $langs = explode( "\n", $msg->text() );
1224 foreach ( $langs as $lang ) {
1225 $lang = trim( $lang, '* ' );
1226 $parts = explode( '|', $lang );
1227 if ( count( $parts ) >= 2 ) {
1228 $links[] = $this->makeLanguageSelectorLink( $parts[0], trim( $parts[1] ) );
1232 return count( $links ) > 0 ?
$this->msg( 'loginlanguagelabel' )->rawParams(
1233 $this->getLanguage()->pipeList( $links ) )->escaped() : '';
1237 * Create a language selector link for a particular language
1238 * Links back to this page preserving type and returnto
1240 * @param string $text Link text
1241 * @param string $lang Language code
1244 protected function makeLanguageSelectorLink( $text, $lang ) {
1245 if ( $this->getLanguage()->getCode() == $lang ) {
1246 // no link for currently used language
1247 return htmlspecialchars( $text );
1249 $query = [ 'uselang' => $lang ];
1250 if ( $this->mReturnTo
!== '' ) {
1251 $query['returnto'] = $this->mReturnTo
;
1252 $query['returntoquery'] = $this->mReturnToQuery
;
1256 $targetLanguage = Language
::factory( $lang );
1257 $attr['lang'] = $attr['hreflang'] = $targetLanguage->getHtmlCode();
1259 return Linker
::linkKnown(
1260 $this->getPageTitle(),
1261 htmlspecialchars( $text ),
1267 protected function getGroupName() {
1272 * @param array $formDescriptor
1274 protected function postProcessFormDescriptor( &$formDescriptor, $requests ) {
1275 // Pre-fill username (if not creating an account, T46775).
1277 isset( $formDescriptor['username'] ) &&
1278 !isset( $formDescriptor['username']['default'] ) &&
1281 $user = $this->getUser();
1282 if ( $user->isLoggedIn() ) {
1283 $formDescriptor['username']['default'] = $user->getName();
1285 $formDescriptor['username']['default'] =
1286 $this->getRequest()->getSession()->suggestLoginUsername();
1290 // don't show a submit button if there is nothing to submit (i.e. the only form content
1291 // is other submit buttons, for redirect flows)
1292 if ( !$this->needsSubmitButton( $requests ) ) {
1293 unset( $formDescriptor['createaccount'], $formDescriptor['loginattempt'] );
1296 if ( !$this->isSignup() ) {
1297 // FIXME HACK don't focus on non-empty field
1298 // maybe there should be an autofocus-if similar to hide-if?
1300 isset( $formDescriptor['username'] )
1301 && empty( $formDescriptor['username']['default'] )
1302 && !$this->getRequest()->getCheck( 'wpName' )
1304 $formDescriptor['username']['autofocus'] = true;
1305 } elseif ( isset( $formDescriptor['password'] ) ) {
1306 $formDescriptor['password']['autofocus'] = true;
1310 $this->addTabIndex( $formDescriptor );
1315 * B/C class to try handling login/signup template modifications even though login/signup does not
1316 * actually happen through a template anymore. Just collects extra field definitions and allows
1317 * some other class to do decide what to do with threm..
1318 * TODO find the right place for adding extra fields and kill this
1320 class FakeAuthTemplate
extends BaseTemplate
{
1321 public function execute() {
1322 throw new LogicException( 'not used' );
1326 * Extensions (AntiSpoof and TitleBlacklist) call this in response to
1327 * UserCreateForm hook to add checkboxes to the create account form.
1329 public function addInputItem( $name, $value, $type, $msg, $helptext = false ) {
1330 // use the same indexes as UserCreateForm just in case someone adds an item manually
1331 $this->data
['extrainput'][] = [
1336 'helptext' => $helptext,
1341 * Turns addInputItem-style field definitions into HTMLForm field definitions.
1344 public function getExtraInputDefinitions() {
1347 foreach ( $this->get( 'extrainput', [] ) as $field ) {
1349 'type' => $field['type'] === 'checkbox' ?
'check' : $field['type'],
1350 'name' => $field['name'],
1351 'value' => $field['value'],
1352 'id' => $field['name'],
1354 if ( $field['msg'] ) {
1355 $definition['label-message'] = $this->getMsg( $field['msg'] );
1357 if ( $field['helptext'] ) {
1358 $definition['help'] = $this->msgWiki( $field['helptext'] );
1361 // the array key doesn't matter much when name is defined explicitly but
1362 // let's try and follow HTMLForm conventions
1363 $name = preg_replace( '/^wp(?=[A-Z])/', '', $field['name'] );
1364 $definitions[$name] = $definition;
1367 if ( $this->haveData( 'extrafields' ) ) {
1368 $definitions['extrafields'] = [
1371 'default' => $this->get( 'extrafields' ),
1375 return $definitions;
1380 * LoginForm as a special page has been replaced by SpecialUserLogin and SpecialCreateAccount,
1381 * but some extensions called its public methods directly, so the class is retained as a
1382 * B/C wrapper. Anything that used it before should use AuthManager instead.
1384 class LoginForm
extends SpecialPage
{
1388 const WRONG_PLUGIN_PASS
= 3;
1389 const NOT_EXISTS
= 4;
1390 const WRONG_PASS
= 5;
1391 const EMPTY_PASS
= 6;
1392 const RESET_PASS
= 7;
1394 const CREATE_BLOCKED
= 9;
1395 const THROTTLED
= 10;
1396 const USER_BLOCKED
= 11;
1397 const NEED_TOKEN
= 12;
1398 const WRONG_TOKEN
= 13;
1399 const USER_MIGRATED
= 14;
1401 public static $statusCodes = [
1402 self
::SUCCESS
=> 'success',
1403 self
::NO_NAME
=> 'no_name',
1404 self
::ILLEGAL
=> 'illegal',
1405 self
::WRONG_PLUGIN_PASS
=> 'wrong_plugin_pass',
1406 self
::NOT_EXISTS
=> 'not_exists',
1407 self
::WRONG_PASS
=> 'wrong_pass',
1408 self
::EMPTY_PASS
=> 'empty_pass',
1409 self
::RESET_PASS
=> 'reset_pass',
1410 self
::ABORTED
=> 'aborted',
1411 self
::CREATE_BLOCKED
=> 'create_blocked',
1412 self
::THROTTLED
=> 'throttled',
1413 self
::USER_BLOCKED
=> 'user_blocked',
1414 self
::NEED_TOKEN
=> 'need_token',
1415 self
::WRONG_TOKEN
=> 'wrong_token',
1416 self
::USER_MIGRATED
=> 'user_migrated',
1420 * @param WebRequest $request
1422 public function __construct( $request = null ) {
1423 wfDeprecated( 'LoginForm', '1.27' );
1424 parent
::__construct();
1428 * @deprecated since 1.27 - call LoginHelper::getValidErrorMessages instead.
1430 public static function getValidErrorMessages() {
1431 return LoginHelper
::getValidErrorMessages();
1435 * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
1437 public static function incrementLoginThrottle( $username ) {
1438 wfDeprecated( __METHOD__
, "1.27" );
1440 $username = User
::getCanonicalName( $username, 'usable' ) ?
: $username;
1441 $throttler = new Throttler();
1442 return $throttler->increase( $username, $wgRequest->getIP(), __METHOD__
);
1446 * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
1448 public static function incLoginThrottle( $username ) {
1449 wfDeprecated( __METHOD__
, "1.27" );
1450 $res = self
::incrementLoginThrottle( $username );
1451 return is_array( $res ) ?
true : 0;
1455 * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
1457 public static function clearLoginThrottle( $username ) {
1458 wfDeprecated( __METHOD__
, "1.27" );
1460 $username = User
::getCanonicalName( $username, 'usable' ) ?
: $username;
1461 $throttler = new Throttler();
1462 return $throttler->clear( $username, $wgRequest->getIP() );
1466 * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
1468 public static function getLoginToken() {
1469 wfDeprecated( __METHOD__
, '1.27' );
1471 return $wgRequest->getSession()->getToken( '', 'login' )->toString();
1475 * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
1477 public static function setLoginToken() {
1478 wfDeprecated( __METHOD__
, '1.27' );
1482 * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
1484 public static function clearLoginToken() {
1485 wfDeprecated( __METHOD__
, '1.27' );
1487 $wgRequest->getSession()->resetToken( 'login' );
1491 * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
1493 public static function getCreateaccountToken() {
1494 wfDeprecated( __METHOD__
, '1.27' );
1496 return $wgRequest->getSession()->getToken( '', 'createaccount' )->toString();
1500 * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
1502 public static function setCreateaccountToken() {
1503 wfDeprecated( __METHOD__
, '1.27' );
1507 * @deprecated since 1.27 - don't use LoginForm, use AuthManager instead
1509 public static function clearCreateaccountToken() {
1510 wfDeprecated( __METHOD__
, '1.27' );
1512 $wgRequest->getSession()->resetToken( 'createaccount' );