32 use Wikimedia\ScopedCallback;
77 abstract protected function successfulAction( $direct =
false, $extraMessages =
null );
89 parent::__construct( $name, $restriction );
95 protected function setRequest( array $data, $wasPosted =
null ) {
96 parent::setRequest( $data, $wasPosted );
97 $this->mLoadedRequest =
false;
104 if ( $this->mLoadedRequest ) {
107 $this->mLoadedRequest =
true;
110 $this->mPosted = $request->wasPosted();
111 $this->mAction = $request->getRawVal(
'action' );
112 $this->mFromHTTP = $request->getBool(
'fromhttp',
false )
113 || $request->getBool(
'wpFromhttp',
false );
114 $this->mStickHTTPS = $this->
getConfig()->get( MainConfigNames::ForceHTTPS )
115 || ( !$this->mFromHTTP && $request->getProtocol() ===
'https' )
116 || $request->getBool(
'wpForceHttps',
false );
117 $this->mLanguage = $request->getText(
'uselang' );
118 $this->mReturnTo = $request->getVal(
'returnto',
'' );
119 $this->mReturnToQuery = $request->getVal(
'returntoquery',
'' );
129 if ( $this->mLoaded ) {
132 $this->mLoaded =
true;
135 $securityLevel = $this->
getRequest()->getText(
'force' );
138 MediaWikiServices::getInstance()->
getAuthManager()->securitySensitiveOperationStatus(
146 $this->mToken = $request->getVal( $this->
getTokenName() );
149 $entryError = $this->
msg( $request->getVal(
'error',
'' ) );
150 $entryWarning = $this->
msg( $request->getVal(
'warning',
'' ) );
155 $this->
msg(
'loginreqlink' )->text(),
158 'returnto' => $this->mReturnTo,
159 'returntoquery' => $this->mReturnToQuery,
160 'uselang' => $this->mLanguage ?:
null,
161 'fromhttp' => $this->
getConfig()->
get( MainConfigNames::SecureLogin ) &&
162 $this->mFromHTTP ?
'1' :
null,
167 if ( $entryError->exists()
170 $this->mEntryErrorType =
'error';
171 $this->mEntryError = $entryError->rawParams( $loginreqlink )->parse();
173 } elseif ( $entryWarning->exists()
176 $this->mEntryErrorType =
'warning';
177 $this->mEntryError = $entryWarning->rawParams( $loginreqlink )->parse();
180 # 1. When switching accounts, it sucks to get automatically logged out
181 # 2. Do not return to PasswordReset after a successful password change
182 # but goto Wiki start page (Main_Page) instead ( T35997 )
184 if ( is_object( $returnToTitle )
185 && ( $returnToTitle->isSpecial(
'Userlogout' )
186 || $returnToTitle->isSpecial(
'PasswordReset' ) )
188 $this->mReturnTo =
'';
189 $this->mReturnToQuery =
'';
194 $params = parent::getPreservedParams( $withToken );
196 'returnto' => $this->mReturnTo ?:
null,
197 'returntoquery' => $this->mReturnToQuery ?:
null,
199 if ( $this->
getConfig()->
get( MainConfigNames::SecureLogin ) && !$this->
isSignup() ) {
200 $params[
'fromhttp'] = $this->mFromHTTP ?
'1' :
null;
208 return parent::beforeExecute(
$subPage );
216 if ( $this->mPosted ) {
217 $time = microtime(
true );
218 $profilingScope =
new ScopedCallback(
function () use ( $time ) {
219 $time = microtime(
true ) - $time;
220 $statsd = MediaWikiServices::getInstance()->getStatsdDataFactory();
221 $statsd->timing(
"timing.login.ui.{$this->authAction}", $time * 1000 );
225 $authManager = MediaWikiServices::getInstance()->getAuthManager();
226 $session = SessionManager::getGlobalSession();
233 $this->
getOutput()->disableClientCache();
241 if ( !$session->canSetUser() ) {
242 throw new ErrorPageError(
'cannotloginnow-title',
'cannotloginnow-text', [
246 throw new ErrorPageError(
'cannotlogin-title',
'cannotlogin-text' );
248 throw new ErrorPageError(
'cannotcreateaccount-title',
'cannotcreateaccount-text' );
269 if ( !$this->
isSignup() && !$this->mPosted && !$this->securityLevel &&
270 ( $this->mReturnTo !==
'' || $this->mReturnToQuery !==
'' ) &&
278 if ( $this->
getRequest()->getProtocol() !==
'https' ) {
282 ( $this->mEntryErrorType ===
'error' ?
'error'
283 :
'warning' ) => $this->mEntryError,
291 $this->
getOutput()->addVaryHeader(
'X-Forwarded-Proto' );
298 if ( substr( $url, 0, 8 ) ===
'https://' ) {
299 $this->mSecureLoginUrl = $url;
308 $this->
mainLoginForm( [],
'authpage-cannot-' . $this->authAction );
315 if ( $button_name ) {
316 $this->
getRequest()->setVal( $button_name,
true );
322 if ( !$status || !$status->isGood() ) {
323 $this->
mainLoginForm( $this->authRequests, $status ? $status->getMessage() :
'',
'error' );
328 $response = $status->getValue();
332 switch ( $response->status ) {
333 case AuthenticationResponse::PASS:
335 $this->proxyAccountCreation = $this->
isSignup() && $this->
getUser()->isNamed();
339 !$this->proxyAccountCreation
340 && $response->loginRequest
346 if ( $response2->status !== AuthenticationResponse::PASS ) {
347 LoggerFactory::getInstance(
'login' )
348 ->error(
'Could not log in after account creation' );
354 if ( !$this->proxyAccountCreation ) {
361 case AuthenticationResponse::FAIL:
363 case AuthenticationResponse::RESTART:
364 unset( $this->authForm );
365 if ( $response->status === AuthenticationResponse::FAIL ) {
367 $messageType =
'error';
370 $messageType =
'warning';
372 $this->
logAuthResult(
false, $response->message ? $response->message->getKey() :
'-' );
374 $this->
mainLoginForm( $this->authRequests, $response->message, $messageType );
376 case AuthenticationResponse::REDIRECT:
377 unset( $this->authForm );
378 $this->
getOutput()->redirect( $response->redirectTarget );
380 case AuthenticationResponse::UI:
381 unset( $this->authForm );
382 $this->authAction = $this->
isSignup() ? AuthManager::ACTION_CREATE_CONTINUE
383 : AuthManager::ACTION_LOGIN_CONTINUE;
384 $this->authRequests = $response->neededRequests;
385 $this->
mainLoginForm( $response->neededRequests, $response->message, $response->messageType );
388 throw new LogicException(
'invalid AuthenticationResponse' );
410 $fields = AuthenticationRequest::mergeFieldInfo( $this->authRequests );
411 foreach ( $fields as $fieldname => $field ) {
412 if ( !isset( $field[
'type'] ) ) {
415 if ( !empty( $field[
'skippable'] ) ) {
418 if ( $field[
'type'] ===
'button' ) {
419 if ( $button_name !==
null ) {
423 $button_name = $fieldname;
425 } elseif ( $field[
'type'] !==
'null' ) {
442 $type,
$title, $msgname, $injected_html, $extraMessages
445 $out->setPageTitle(
$title );
449 if ( $extraMessages ) {
451 $out->addWikiTextAsInterface(
452 $extraMessages->getWikiText(
false,
false, $this->getLanguage() )
456 $out->addHTML( $injected_html );
459 $helper->showReturnToPage(
$type, $this->mReturnTo, $this->mReturnToQuery, $this->mStickHTTPS );
478 $type, $returnTo =
'', $returnToQuery =
'', $stickHTTPS =
false
481 $helper->showReturnToPage(
$type, $returnTo, $returnToQuery, $stickHTTPS );
493 if ( $context !== $localContext ) {
498 $user = $context->getRequest()->getSession()->getUser();
501 $context->setUser( $user );
503 $wgLang = $context->getLanguage();
520 protected function mainLoginForm( array $requests, $msg =
'', $msgtype =
'error' ) {
528 $this->authForm =
null;
529 $requests = MediaWikiServices::getInstance()->getAuthManager()
530 ->getAuthenticationRequests( $this->authAction, $user );
534 $out->addModuleStyles( [
536 'mediawiki.ui.button',
537 'mediawiki.ui.checkbox',
538 'mediawiki.ui.input',
539 'mediawiki.special.userlogin.common.styles'
543 $out->addJsConfigVars(
'wgCreateacctImgcaptchaHelp',
544 $this->
msg(
'createacct-imgcaptcha-help' )->parse() );
547 $out->addModules(
'mediawiki.special.createaccount' );
548 $out->addModuleStyles( [
549 'mediawiki.special.userlogin.signup.styles'
553 $out->addModuleStyles( [
554 'mediawiki.special.userlogin.login.styles'
557 $out->disallowUserJs();
559 $form = $this->
getAuthForm( $requests, $this->authAction, $msg, $msgtype );
560 $form->prepareForm();
563 if ( $msg && $msgtype ===
'warning' ) {
564 $submitStatus->warning( $msg );
565 } elseif ( $msg && $msgtype ===
'error' ) {
566 $submitStatus->fatal( $msg );
572 $this->
getUser()->isRegistered() &&
574 $this->authAction !== AuthManager::ACTION_LOGIN_CONTINUE
576 $reauthMessage = $this->securityLevel ?
'userlogin-reauth' :
'userlogin-loggedin';
577 $submitStatus->warning( $reauthMessage, $this->
getUser()->
getName() );
580 $formHtml = $form->getHTML( $submitStatus );
593 [
'id' =>
'userloginprompt' ], $this->
msg(
'loginprompt' )->parseAsBlock() );
594 $languageLinks = $this->
getConfig()->get( MainConfigNames::LoginLanguageSelector )
596 $signupStartMsg = $this->
msg(
'signupstart' );
597 $signupStart = ( $this->
isSignup() && !$signupStartMsg->isDisabled() )
598 ?
Html::rawElement(
'div', [
'id' =>
'signupstart' ], $signupStartMsg->parseAsBlock() ) :
'';
599 if ( $languageLinks ) {
622 $benefitsContainer =
'';
630 for ( $benefitIdx = 1; $benefitIdx <= $benefitCount; $benefitIdx++ ) {
631 $headUnescaped = $this->
msg(
"createacct-benefit-head$benefitIdx" )->text();
632 $iconClass = $this->
msg(
"createacct-benefit-icon$benefitIdx" )->text();
633 $benefitList .=
Html::rawElement(
'div', [
'class' =>
"mw-number-text $iconClass" ],
635 $this->
msg(
"createacct-benefit-head$benefitIdx" )->escaped()
638 $this->
msg(
"createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped()
642 $benefitsContainer =
Html::rawElement(
'div', [
'class' =>
'mw-createacct-benefits-container' ],
644 .
Html::rawElement(
'div', [
'class' =>
'mw-createacct-benefits-list' ], $benefitList )
647 return $benefitsContainer;
658 protected function getAuthForm( array $requests, $action, $msg =
'', $msgType =
'error' ) {
661 if ( isset( $this->authForm ) ) {
662 return $this->authForm;
665 $usingHTTPS = $this->getRequest()->getProtocol() ===
'https';
668 $fieldInfo = AuthenticationRequest::mergeFieldInfo( $requests );
670 $formDescriptor = $this->fieldInfoToFormDescriptor( $requests, $fieldInfo, $this->authAction );
671 $this->postProcessFormDescriptor( $formDescriptor, $requests );
674 if ( $context->getRequest() !== $this->getRequest() ) {
677 $context->setRequest( $this->getRequest() );
681 $form->addHiddenField(
'authAction', $this->authAction );
682 if ( $this->mLanguage ) {
683 $form->addHiddenField(
'uselang', $this->mLanguage );
685 $form->addHiddenField(
'force', $this->securityLevel );
686 $form->addHiddenField( $this->getTokenName(), $this->getToken()->toString() );
687 $config = $this->getConfig();
688 if ( $config->get( MainConfigNames::SecureLogin ) &&
689 !$config->get( MainConfigNames::ForceHTTPS ) ) {
691 if ( !$this->isSignup() ) {
692 $form->addHiddenField(
'wpForceHttps', (
int)$this->mStickHTTPS );
693 $form->addHiddenField(
'wpFromhttp', $usingHTTPS );
698 $form->setAction( $this->getPageTitle()->getLocalURL( $this->getReturnToQueryStringFragment() ) );
699 $form->setName(
'userlogin' . ( $this->isSignup() ?
'2' :
'' ) );
700 if ( $this->isSignup() ) {
701 $form->setId(
'userlogin2' );
704 $form->suppressDefaultSubmit();
706 $this->authForm = $form;
713 array $requests, array $fieldInfo, array &$formDescriptor, $action
715 $formDescriptor = self::mergeDefaultFormDescriptor( $fieldInfo, $formDescriptor,
716 $this->getFieldDefinitions( $fieldInfo ) );
726 return $this->authAction !== $this->getContinueAction( $this->authAction )
727 && !$this->securityLevel;
736 $isLoggedIn = $this->
getUser()->isRegistered();
737 $continuePart = $this->isContinued() ?
'continue-' :
'';
738 $anotherPart = $isLoggedIn ?
'another-' :
'';
740 $expiration = $this->getRequest()->getSession()->getProvider()->getRememberUserDuration();
741 $expirationDays = ceil( $expiration / ( 3600 * 24 ) );
742 $secureLoginLink =
'';
743 if ( $this->mSecureLoginUrl ) {
745 'href' => $this->mSecureLoginUrl,
746 'class' =>
'mw-ui-flush-right mw-secure',
747 ], $this->msg(
'userlogin-signwithsecure' )->text() );
749 $usernameHelpLink =
'';
750 if ( !$this->msg(
'createacct-helpusername' )->isDisabled() ) {
752 'class' =>
'mw-ui-flush-right',
753 ], $this->msg(
'createacct-helpusername' )->parse() );
756 if ( $this->isSignup() ) {
757 $config = $this->getConfig();
758 $hideIf = isset( $fieldInfo[
'mailpassword'] ) ? [
'hide-if' => [
'===',
'mailpassword',
'1' ] ] : [];
759 $fieldDefinitions = [
765 'default' =>
Html::element(
'div', [
'id' =>
'mw-createacct-status-area' ] ),
769 'label-raw' => $this->msg(
'userlogin-yourname' )->escaped() . $usernameHelpLink,
771 'placeholder-message' => $isLoggedIn ?
'createacct-another-username-ph'
772 :
'userlogin-yourname-ph',
777 'label-message' =>
'createaccountmail',
778 'name' =>
'wpCreateaccountMail',
779 'id' =>
'wpCreateaccountMail',
782 'id' =>
'wpPassword2',
783 'autocomplete' =>
'new-password',
784 'placeholder-message' =>
'createacct-yourpassword-ph',
785 'help-message' =>
'createacct-useuniquepass',
789 'type' =>
'password',
790 'label-message' =>
'createacct-yourpasswordagain',
792 'cssclass' =>
'loginPassword',
794 'autocomplete' =>
'new-password',
795 'validation-callback' =>
function ( $value, $alldata ) {
796 if ( empty( $alldata[
'mailpassword'] ) && !empty( $alldata[
'password'] ) ) {
798 return $this->msg(
'htmlform-required' );
799 } elseif ( $value !== $alldata[
'password'] ) {
800 return $this->msg(
'badretype' );
805 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
809 'label-message' => $config->get( MainConfigNames::EmailConfirmToEdit )
810 ?
'createacct-emailrequired' :
'createacct-emailoptional',
812 'cssclass' =>
'loginText',
814 'autocomplete' =>
'email',
816 'required' => $config->get( MainConfigNames::EmailConfirmToEdit ),
817 'validation-callback' =>
function ( $value, $alldata ) {
821 $this->getConfig()->get( MainConfigNames::EmailConfirmToEdit ) ) {
824 return $this->msg(
'noemailtitle' );
825 } elseif ( !$value && !empty( $alldata[
'mailpassword'] ) ) {
827 return $this->msg(
'noemailcreate' );
829 return $this->msg(
'invalidemailaddress' );
833 'placeholder-message' =>
'createacct-' . $anotherPart .
'email-ph',
837 'help-message' => $isLoggedIn ?
'createacct-another-realname-tip'
838 :
'prefs-help-realname',
839 'label-message' =>
'createacct-realname',
840 'cssclass' =>
'loginText',
842 'id' =>
'wpRealName',
843 'autocomplete' =>
'name',
848 'label-message' =>
'createacct-reason',
849 'cssclass' =>
'loginText',
852 'validation-callback' =>
function ( $value, $alldata ) {
856 if ( $this->reasonValidatorResult !==
null ) {
857 return $this->reasonValidatorResult;
859 $this->reasonValidatorResult =
true;
860 $authManager = MediaWikiServices::getInstance()->getAuthManager();
861 if ( !$authManager->getAuthenticationSessionData(
'reason-retry',
false ) ) {
862 $authManager->setAuthenticationSessionData(
'reason-retry',
true );
863 $this->reasonValidatorResult = $this->msg(
'createacct-reason-confirm' );
865 return $this->reasonValidatorResult;
869 'placeholder-message' =>
'createacct-reason-ph',
874 'default' => $this->msg(
'createacct-' . $anotherPart . $continuePart .
876 'name' =>
'wpCreateaccount',
877 'id' =>
'wpCreateaccount',
885 $passwordRequest = AuthenticationRequest::getRequestByClass( $this->authRequests,
886 PasswordAuthenticationRequest::class );
887 $changePassword = $passwordRequest && $passwordRequest->action == AuthManager::ACTION_CHANGE;
888 $fieldDefinitions = [
891 'label-raw' => $this->msg(
'userlogin-yourname' )->escaped() . $secureLoginLink,
893 'placeholder-message' =>
'userlogin-yourname-ph',
894 ] + ( $changePassword ? [
897 'baseField' =>
'password',
900 'cssclass' =>
'mw-htmlform-hidden-field',
905 'autocomplete' =>
'new-password',
906 'placeholder-message' =>
'createacct-yourpassword-ph',
907 'help-message' =>
'createacct-useuniquepass',
909 'id' =>
'wpPassword1',
910 'autocomplete' =>
'current-password',
911 'placeholder-message' =>
'userlogin-yourpassword-ph',
915 'type' =>
'password',
916 'autocomplete' =>
'new-password',
917 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
923 'cssclass' =>
'mw-userlogin-rememberme',
924 'name' =>
'wpRemember',
925 'label-message' => $this->msg(
'userlogin-remembermypassword' )
926 ->numParams( $expirationDays ),
927 'id' =>
'wpRemember',
932 'default' => $this->msg(
'pt-login-' . $continuePart .
'button' )->text(),
933 'id' =>
'wpLoginAttempt',
939 'cssclass' =>
'mw-form-related-link-container mw-userlogin-help',
944 ->inContentLanguage()
946 ], $this->msg(
'userlogin-helplink2' )->text() ),
957 $fieldDefinitions[
'username'] += [
960 'cssclass' =>
'loginText',
962 'autocomplete' =>
'username',
965 $fieldDefinitions[
'password'] += [
966 'type' =>
'password',
968 'name' =>
'wpPassword',
969 'cssclass' =>
'loginPassword',
974 if ( $this->mEntryError ) {
976 if ( $this->mEntryErrorType ===
'error' ) {
978 } elseif ( $this->mEntryErrorType ===
'warning' ) {
981 $fieldDefinitions[
'entryError'] = [
983 'default' => $defaultHtml,
989 if ( $this->isSignup() && $this->
getUser()->isTemp() ) {
990 $fieldDefinitions[
'tempWarning'] = [
993 $this->msg(
'createacct-temp-warning' )->parse()
1000 if ( !$this->showExtraInformation() ) {
1001 unset( $fieldDefinitions[
'linkcontainer'], $fieldDefinitions[
'signupend'] );
1003 if ( $this->isSignup() && $this->showExtraInformation() ) {
1006 $signupendMsg = $this->msg(
'signupend' );
1007 $signupendHttpsMsg = $this->msg(
'signupend-https' );
1008 if ( !$signupendMsg->isDisabled() ) {
1009 $usingHTTPS = $this->getRequest()->getProtocol() ===
'https';
1010 $signupendText = ( $usingHTTPS && !$signupendHttpsMsg->isBlank() )
1011 ? $signupendHttpsMsg->parse() : $signupendMsg->parse();
1012 $fieldDefinitions[
'signupend'] = [
1015 'default' =>
Html::rawElement(
'div', [
'id' =>
'signupend' ], $signupendText ),
1020 if ( !$this->isSignup() && $this->showExtraInformation() ) {
1021 $passwordReset = MediaWikiServices::getInstance()->getPasswordReset();
1022 if ( $passwordReset->isAllowed( $this->getUser() )->isGood() ) {
1023 $fieldDefinitions[
'passwordReset'] = [
1026 'cssclass' =>
'mw-form-related-link-container',
1027 'default' => $this->getLinkRenderer()->makeLink(
1029 $this->msg(
'userlogin-resetpassword-link' )->text()
1036 if ( $this->showCreateAccountLink() ) {
1038 $linkTitle = $this->getTitleFor( $this->isSignup() ?
'Userlogin' :
'CreateAccount' );
1039 $linkq = $this->getReturnToQueryStringFragment();
1041 if ( $this->mLanguage ) {
1042 $linkq .=
'&uselang=' . urlencode( $this->mLanguage );
1044 $isLoggedIn = $this->
getUser()->isRegistered()
1045 && !$this->
getUser()->isTemp();
1047 $fieldDefinitions[
'createOrLogin'] = [
1050 'linkQuery' => $linkq,
1051 'default' =>
function ( $params ) use ( $isLoggedIn, $linkTitle ) {
1053 [
'id' =>
'mw-createaccount' . ( !$isLoggedIn ?
'-cta' :
'' ),
1054 'class' => ( $isLoggedIn ?
'mw-form-related-link-container' :
'mw-ui-vform-field' ) ],
1055 ( $isLoggedIn ?
'' : $this->msg(
'userlogin-noaccount' )->escaped() )
1058 'id' =>
'mw-createaccount-join' . ( $isLoggedIn ?
'-loggedin' :
'' ),
1059 'href' => $linkTitle->getLocalURL( $params[
'linkQuery'] ),
1060 'class' => ( $isLoggedIn ?
'' :
'mw-ui-button' ),
1064 $isLoggedIn ?
'userlogin-createanother' :
'userlogin-joinproject'
1074 return $fieldDefinitions;
1087 $config = $this->getConfig();
1088 return $config->get( MainConfigNames::DisableCookieCheck ) || (
1089 $config->get(
'InitialSessionId' ) &&
1090 $this->getRequest()->getSession()->getId() === (string)$config->get(
'InitialSessionId' )
1101 if ( $this->mReturnTo !==
'' ) {
1102 $returnto =
'returnto=' .
wfUrlencode( $this->mReturnTo );
1103 if ( $this->mReturnToQuery !==
'' ) {
1104 $returnto .=
'&returntoquery=' .
wfUrlencode( $this->mReturnToQuery );
1116 return $this->isSignup() ||
1117 $this->
getContext()->getAuthority()->isAllowed(
'createaccount' );
1121 return $this->isSignup() ?
'wpCreateaccountToken' :
'wpLoginToken';
1131 $msg = $this->msg(
'loginlanguagelinks' )->inContentLanguage();
1132 if ( $msg->isBlank() ) {
1135 $langs = explode(
"\n", $msg->text() );
1137 foreach ( $langs as
$lang ) {
1139 $parts = explode(
'|',
$lang );
1140 if ( count( $parts ) >= 2 ) {
1141 $links[] = $this->makeLanguageSelectorLink( $parts[0], trim( $parts[1] ) );
1145 return count( $links ) > 0 ? $this->msg(
'loginlanguagelabel' )->rawParams(
1146 $this->getLanguage()->pipeList( $links ) )->escaped() :
'';
1158 if ( $this->getLanguage()->getCode() ==
$lang ) {
1160 return htmlspecialchars( $text );
1162 $query = [
'uselang' =>
$lang ];
1163 if ( $this->mReturnTo !==
'' ) {
1164 $query[
'returnto'] = $this->mReturnTo;
1165 $query[
'returntoquery'] = $this->mReturnToQuery;
1169 $targetLanguage = MediaWikiServices::getInstance()->getLanguageFactory()
1170 ->getLanguage(
$lang );
1171 $attr[
'lang'] = $attr[
'hreflang'] = $targetLanguage->getHtmlCode();
1173 return $this->getLinkRenderer()->makeKnownLink(
1174 $this->getPageTitle(),
1192 isset( $formDescriptor[
'username'] ) &&
1193 !isset( $formDescriptor[
'username'][
'default'] ) &&
1197 if ( $user->isRegistered() && !$user->isTemp() ) {
1198 $formDescriptor[
'username'][
'default'] = $user->getName();
1200 $formDescriptor[
'username'][
'default'] =
1201 $this->getRequest()->getSession()->suggestLoginUsername();
1207 if ( !$this->needsSubmitButton( $requests ) ) {
1208 unset( $formDescriptor[
'createaccount'], $formDescriptor[
'loginattempt'] );
1211 if ( !$this->isSignup() ) {
1215 isset( $formDescriptor[
'username'] )
1216 && empty( $formDescriptor[
'username'][
'default'] )
1217 && !$this->getRequest()->getCheck(
'wpName' )
1219 $formDescriptor[
'username'][
'autofocus'] =
true;
1220 } elseif ( isset( $formDescriptor[
'password'] ) ) {
1221 $formDescriptor[
'password'][
'autofocus'] =
true;
1225 $this->addTabIndex( $formDescriptor );
$wgUseMediaWikiUIEverywhere
Variable for the UseMediaWikiUIEverywhere setting, for use in LocalSettings.php.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgLang
A special page subclass for authentication-related special pages.
getContinueAction( $action)
Gets the _CONTINUE version of an action.
isActionAllowed( $action)
Checks whether AuthManager is ready to perform the action.
loadAuth( $subPage, $authAction=null, $reset=false)
Load or initialize $authAction, $authRequests and $subPage.
getDefaultAction( $subPage)
Get the default action for this special page, if none is given via URL/POST data.
string $subPage
Subpage of the special page.
isContinued()
Returns true if this is not the first step of the authentication.
getRequest()
Get the WebRequest being used for this instance.
trySubmit()
Attempts to do an authentication step with the submitted data.
getToken()
Returns the CSRF token.
An IContextSource implementation which will inherit context from another source but allow individual ...
An error page which can definitely be safely rendered using the OutputPage.
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static warningBox( $html, $className='')
Return a warning box.
static errorBox( $html, $heading='', $className='')
Return an error box.
Helper functions for the login form that need to be shared with other special pages (such as CentralA...
static getValidErrorMessages()
Returns an array of all valid error messages.
Holds shared logic for login and account creation pages.
mainLoginForm(array $requests, $msg='', $msgtype='error')
canBypassForm(&$button_name)
Determine if the login form can be bypassed.
getPreservedParams( $withToken=false)
Returns URL query parameters which can be used to reload the page (or leave and return) while preserv...
logAuthResult( $success, $status=null)
Logs to the authmanager-stats channel.
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
Change the form descriptor that determines how a field will look in the authentication form....
setSessionUserForCurrentRequest()
Replace some globals to make sure the fact that the user has just been logged in is reflected in the ...
getBenefitsContainerHtml()
The HTML to be shown in the "benefits to signing in / creating an account" section of the signup/logi...
showSuccessPage( $type, $title, $msgname, $injected_html, $extraMessages)
Show the success page.
getFieldDefinitions(array $fieldInfo)
Create a HTMLForm descriptor for the core login fields.
getReturnToQueryStringFragment()
Returns a string that can be appended to the URL (without encoding) to preserve the return target.
User $targetUser
FIXME another flag for passing data.
successfulAction( $direct=false, $extraMessages=null)
showExtraInformation()
Show extra information such as password recovery information, link from login to signup,...
getPageHtml( $formHtml)
Add page elements which are outside the form.
hasSessionCookie()
Check if a session cookie is present.
loadRequestParameters()
Load basic request parameters for this Special page.
__construct( $name, $restriction='')
getAuthForm(array $requests, $action, $msg='', $msgType='error')
Generates a form from the given request.
getTokenName()
Returns the name of the CSRF token (under which it should be found in the POST or GET data).
makeLanguageSelectorLink( $text, $lang)
Create a language selector link for a particular language Links back to this page preserving type and...
bool $proxyAccountCreation
True if the user if creating an account for someone else.
showCreateAccountLink()
Whether the login/create account form should display a link to the other form (in addition to whateve...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
postProcessFormDescriptor(&$formDescriptor, $requests)
setRequest(array $data, $wasPosted=null)
Override the POST data, GET data from the real request is preserved.
showReturnToPage( $type, $returnTo='', $returnToQuery='', $stickHTTPS=false)
Add a "return to" link or redirect to it.
makeLanguageSelector()
Produce a bar of links which allow the user to select another language during login/registration but ...
load( $subPage)
Load data from request.
A class containing constants representing the names of configuration variables.
static getMain()
Get the RequestContext object associated with the main request.
static validateEmail( $addr)
Does a string look like an e-mail address?
static makeInternalOrExternalUrl( $name)
If url string starts with http, consider as external URL, else internal.
setContext( $context)
Sets the context this SpecialPage is executed in.
getName()
Get the name of this Special Page.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
AuthManager null $authManager
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getPageTitle( $subpage=false)
Get a self-referential title object.
getFullTitle()
Return the full title, including $par.
static newFatal( $message,... $parameters)
Factory function for fatal errors.
static newGood( $value=null)
Factory function for good results.
static wrap( $sv)
Succinct helper method to wrap a StatusValue.
static setUser( $user)
Reset the stub global user to a different "real" user object, while ensuring that any method calls on...
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
static newFromName( $name, $validate='valid')
if(!isset( $args[0])) $lang