Go to the documentation of this file.
67 abstract protected function isSignup();
75 abstract protected function successfulAction( $direct =
false, $extraMessages =
null );
85 global $wgUseMediaWikiUIEverywhere;
86 parent::__construct(
$name );
89 $wgUseMediaWikiUIEverywhere =
true;
93 parent::setRequest( $data, $wasPosted );
94 $this->mLoadedRequest =
false;
102 if ( $this->mLoadedRequest ) {
105 $this->mLoadedRequest =
true;
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',
'' );
129 if ( $this->mLoaded ) {
132 $this->mLoaded =
true;
137 $securityLevel && AuthManager::singleton()->securitySensitiveOperationStatus(
148 $entryError = $this->
msg(
$request->getVal(
'error',
'' ) );
149 $entryWarning = $this->
msg(
$request->getVal(
'warning',
'' ) );
154 $this->
msg(
'loginreqlink' )->
text(),
157 'returnto' => $this->mReturnTo,
158 'returntoquery' => $this->mReturnToQuery,
159 'uselang' => $this->mLanguage ?:
null,
160 'fromhttp' => $wgSecureLogin && $this->mFromHTTP ?
'1' :
null,
165 if ( $entryError->exists()
168 $this->mEntryErrorType =
'error';
169 $this->mEntryError = $entryError->rawParams( $loginreqlink )->parse();
171 } elseif ( $entryWarning->exists()
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 ( T35997 )
182 if ( is_object( $returnToTitle )
183 && ( $returnToTitle->isSpecial(
'Userlogout' )
184 || $returnToTitle->isSpecial(
'PasswordReset' ) )
186 $this->mReturnTo =
'';
187 $this->mReturnToQuery =
'';
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;
208 return parent::beforeExecute(
$subPage );
215 $authManager = AuthManager::singleton();
216 $session = SessionManager::getGlobalSession();
227 if ( !$this->
isSignup() && !$authManager->canAuthenticateNow() ) {
228 if ( !$session->canSetUser() ) {
229 throw new ErrorPageError(
'cannotloginnow-title',
'cannotloginnow-text', [
233 throw new ErrorPageError(
'cannotlogin-title',
'cannotlogin-text' );
234 } elseif ( $this->
isSignup() && !$authManager->canCreateAccounts() ) {
235 throw new ErrorPageError(
'cannotcreateaccount-title',
'cannotcreateaccount-text' );
252 if ( !$this->
isSignup() && !$this->mPosted && !$this->securityLevel &&
253 ( $this->mReturnTo !==
'' || $this->mReturnToQuery !==
'' ) &&
261 if ( $this->
getRequest()->getProtocol() !==
'https' ) {
265 ( $this->mEntryErrorType ===
'error' ?
'error'
266 :
'warning' ) => $this->mEntryError,
269 if ( $wgSecureLogin && !$this->mFromHTTP &&
276 $this->
getOutput()->addVaryHeader(
'X-Forwarded-Proto' );
283 if ( substr( $url, 0, 8 ) ===
'https://' ) {
284 $this->mSecureLoginUrl = $url;
293 $this->
mainLoginForm( [],
'authpage-cannot-' . $this->authAction );
300 if ( $button_name ) {
301 $this->
getRequest()->setVal( $button_name,
true );
318 case AuthenticationResponse::PASS:
320 $this->proxyAccountCreation = $this->
isSignup() && !$this->
getUser()->isAnon();
324 !$this->proxyAccountCreation
326 && $authManager->canAuthenticateNow()
329 $response2 = $authManager->beginAuthentication( [
$response->loginRequest ],
331 if ( $response2->status !== AuthenticationResponse::PASS ) {
332 LoggerFactory::getInstance(
'login' )
333 ->error(
'Could not log in after account creation' );
339 if ( !$this->proxyAccountCreation ) {
346 case AuthenticationResponse::FAIL:
348 case AuthenticationResponse::RESTART:
349 unset( $this->authForm );
350 if (
$response->status === AuthenticationResponse::FAIL ) {
352 $messageType =
'error';
355 $messageType =
'warning';
361 case AuthenticationResponse::REDIRECT:
362 unset( $this->authForm );
365 case AuthenticationResponse::UI:
366 unset( $this->authForm );
367 $this->authAction = $this->
isSignup() ? AuthManager::ACTION_CREATE_CONTINUE
368 : AuthManager::ACTION_LOGIN_CONTINUE;
369 $this->authRequests =
$response->neededRequests;
373 throw new LogicException(
'invalid AuthenticationResponse' );
395 $fields = AuthenticationRequest::mergeFieldInfo( $this->authRequests );
396 foreach ( $fields
as $fieldname => $field ) {
397 if ( !isset( $field[
'type'] ) ) {
400 if ( !empty( $field[
'skippable'] ) ) {
403 if ( $field[
'type'] ===
'button' ) {
404 if ( $button_name !==
null ) {
408 $button_name = $fieldname;
410 } elseif ( $field[
'type'] !==
'null' ) {
427 $type,
$title, $msgname, $injected_html, $extraMessages
434 if ( $extraMessages ) {
436 $out->addWikiText( $extraMessages->getWikiText() );
439 $out->addHTML( $injected_html );
442 $helper->showReturnToPage(
$type, $this->mReturnTo, $this->mReturnToQuery, $this->mStickHTTPS );
516 $this->authForm =
null;
517 $requests = AuthManager::singleton()->getAuthenticationRequests( $this->authAction,
$user );
521 $out->addModuleStyles( [
523 'mediawiki.ui.button',
524 'mediawiki.ui.checkbox',
525 'mediawiki.ui.input',
526 'mediawiki.special.userlogin.common.styles'
530 $out->addJsConfigVars(
'wgCreateacctImgcaptchaHelp',
531 $this->
msg(
'createacct-imgcaptcha-help' )->parse() );
535 'mediawiki.special.userlogin.signup.js'
537 $out->addModuleStyles( [
538 'mediawiki.special.userlogin.signup.styles'
542 $out->addModuleStyles( [
543 'mediawiki.special.userlogin.login.styles'
546 $out->disallowUserJs();
548 $form = $this->
getAuthForm( $requests, $this->authAction, $msg, $msgtype );
549 $form->prepareForm();
552 if ( $msg && $msgtype ===
'warning' ) {
553 $submitStatus->warning( $msg );
554 } elseif ( $msg && $msgtype ===
'error' ) {
555 $submitStatus->fatal( $msg );
561 $this->
getUser()->isLoggedIn() &&
562 $this->authAction !== AuthManager::ACTION_LOGIN_CONTINUE
564 $reauthMessage = $this->securityLevel ?
'userlogin-reauth' :
'userlogin-loggedin';
565 $submitStatus->warning( $reauthMessage, $this->
getUser()->
getName() );
568 $formHtml = $form->getHTML( $submitStatus );
580 global $wgLoginLanguageSelector;
583 [
'id' =>
'userloginprompt' ], $this->
msg(
'loginprompt' )->parseAsBlock() );
585 $signupStartMsg = $this->
msg(
'signupstart' );
586 $signupStart = ( $this->
isSignup() && !$signupStartMsg->isDisabled() )
587 ?
Html::rawElement(
'div', [
'id' =>
'signupstart' ], $signupStartMsg->parseAsBlock() ) :
'';
588 if ( $languageLinks ) {
594 $benefitsContainer =
'';
602 for ( $benefitIdx = 1; $benefitIdx <= $benefitCount; $benefitIdx++ ) {
603 $headUnescaped = $this->
msg(
"createacct-benefit-head$benefitIdx" )->text();
604 $iconClass = $this->
msg(
"createacct-benefit-icon$benefitIdx" )->escaped();
605 $benefitList .=
Html::rawElement(
'div', [
'class' =>
"mw-number-text $iconClass" ],
607 $this->
msg(
"createacct-benefit-head$benefitIdx" )->escaped()
610 $this->
msg(
"createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped()
614 $benefitsContainer =
Html::rawElement(
'div', [
'class' =>
'mw-createacct-benefits-container' ],
647 if ( isset( $this->authForm ) ) {
651 $usingHTTPS = $this->
getRequest()->getProtocol() ===
'https';
654 $fieldInfo = AuthenticationRequest::mergeFieldInfo(
$requests );
658 $formDescriptor = static::fieldInfoToFormDescriptor(
$requests, $fieldInfo, $this->authAction );
669 $form->addHiddenField(
'authAction', $this->authAction );
670 if ( $this->mLanguage ) {
671 $form->addHiddenField(
'uselang', $this->mLanguage );
673 $form->addHiddenField(
'force', $this->securityLevel );
675 if ( $wgSecureLogin ) {
678 $form->addHiddenField(
'wpForceHttps', (
int)$this->mStickHTTPS );
679 $form->addHiddenField(
'wpFromhttp', $usingHTTPS );
685 $form->setName(
'userlogin' . ( $this->
isSignup() ?
'2' :
'' ) );
687 $form->setId(
'userlogin2' );
690 $form->suppressDefaultSubmit();
692 $this->authForm = $form;
705 $wgSecureLogin, $wgPasswordResetRoutes;
711 'mUsername' =>
$request->getText(
'wpName' ),
712 'mPassword' =>
$request->getText(
'wpPassword' ),
713 'mRetype' =>
$request->getText(
'wpRetype' ),
714 'mEmail' =>
$request->getText(
'wpEmail' ),
715 'mRealName' =>
$request->getText(
'wpRealName' ),
716 'mDomain' =>
$request->getText(
'wpDomain' ),
717 'mReason' =>
$request->getText(
'wpReason' ),
718 'mRemember' =>
$request->getCheck(
'wpRemember' ),
731 if ( $data->mUsername ==
'' && $this->isSignup() ) {
732 if (
$user->isLoggedIn() ) {
733 $data->mUsername =
$user->getName();
735 $data->mUsername = $this->
getRequest()->getSession()->suggestLoginUsername();
743 $q =
'action=submitlogin&type=signup';
744 $linkq =
'type=login';
746 $q =
'action=submitlogin&type=login';
747 $linkq =
'type=signup';
750 if ( $this->mReturnTo !==
'' ) {
751 $returnto =
'&returnto=' .
wfUrlencode( $this->mReturnTo );
752 if ( $this->mReturnToQuery !==
'' ) {
753 $returnto .=
'&returntoquery=' .
760 # Don't show a "create account" link if the user can't.
762 # Pass any language selection on to the mode switch link
763 if ( $this->mLanguage ) {
767 $template->set(
'createOrLoginHref', $titleObj->getLocalURL( $linkq ) );
774 : is_array( $wgPasswordResetRoutes )
775 && in_array(
true, array_values( $wgPasswordResetRoutes ),
true );
781 $template->set(
'name', $data->mUsername );
782 $template->set(
'password', $data->mPassword );
783 $template->set(
'retype', $data->mRetype );
784 $template->set(
'createemailset',
false );
785 $template->set(
'email', $data->mEmail );
786 $template->set(
'realname', $data->mRealName );
787 $template->set(
'domain', $data->mDomain );
788 $template->set(
'reason', $data->mReason );
789 $template->set(
'remember', $data->mRemember );
791 $template->set(
'action', $titleObj->getLocalURL( $q ) );
793 $template->set(
'messagetype', $msgType );
795 $template->set(
'userealname', !in_array(
'realname', $wgHiddenPrefs,
true ) );
797 $template->set(
'emailrequired', $wgEmailConfirmToEdit );
799 $template->set(
'canreset', $wgAuth->allowPasswordChange() );
800 $template->set(
'resetlink', $resetLink );
802 ->getRememberUserDuration() !== null );
804 $template->set(
'cansecurelogin', ( $wgSecureLogin ) );
805 $template->set(
'stickhttps', (
int)$this->mStickHTTPS );
810 $action = $this->
isSignup() ?
'signup' :
'login';
811 $wgAuth->modifyUITemplate(
$template, $action );
819 wfDeprecated(
"reference in UserCreateForm hook",
'1.27' );
824 wfDeprecated(
"reference in UserLoginForm hook",
'1.27' );
835 $specialFields = array_merge( [
'extraInput' ],
836 array_keys( $this->fakeTemplate->getExtraInputDefinitions() ) );
839 foreach ( $coreFieldDescriptors
as $fieldName => $coreField ) {
840 $requestField = isset( $formDescriptor[$fieldName] ) ?
841 $formDescriptor[$fieldName] : [];
847 !isset( $fieldInfo[$fieldName] )
849 !isset( $coreField[
'baseField'] )
850 || !isset( $fieldInfo[$coreField[
'baseField']] )
852 && !in_array( $fieldName, $specialFields,
true )
854 !isset( $coreField[
'type'] )
855 || !in_array( $coreField[
'type'], [
'submit',
'info' ],
true )
858 $coreFieldDescriptors[$fieldName] =
null;
864 isset( $coreField[
'label'] )
865 || isset( $coreField[
'label-message'] )
866 || isset( $coreField[
'label-raw'] )
868 unset( $requestField[
'label'], $requestField[
'label-message'], $coreField[
'label-raw'] );
871 $coreFieldDescriptors[$fieldName] += $requestField;
874 $formDescriptor = array_filter( $coreFieldDescriptors + $formDescriptor );
895 global $wgEmailConfirmToEdit;
897 $isLoggedIn = $this->
getUser()->isLoggedIn();
898 $continuePart = $this->
isContinued() ?
'continue-' :
'';
899 $anotherPart = $isLoggedIn ?
'another-' :
'';
900 $expiration = $this->
getRequest()->getSession()->getProvider()->getRememberUserDuration();
901 $expirationDays = ceil( $expiration / ( 3600 * 24 ) );
902 $secureLoginLink =
'';
903 if ( $this->mSecureLoginUrl ) {
905 'href' => $this->mSecureLoginUrl,
906 'class' =>
'mw-ui-flush-right mw-secure',
907 ], $this->
msg(
'userlogin-signwithsecure' )->
text() );
909 $usernameHelpLink =
'';
910 if ( !$this->
msg(
'createacct-helpusername' )->isDisabled() ) {
912 'class' =>
'mw-ui-flush-right',
913 ], $this->
msg(
'createacct-helpusername' )->parse() );
917 $fieldDefinitions = [
923 'default' =>
Html::element(
'div', [
'id' =>
'mw-createacct-status-area' ] ),
927 'label-raw' => $this->
msg(
'userlogin-yourname' )->escaped() . $usernameHelpLink,
929 'placeholder-message' => $isLoggedIn ?
'createacct-another-username-ph'
930 :
'userlogin-yourname-ph',
935 'label-message' =>
'createaccountmail',
936 'name' =>
'wpCreateaccountMail',
937 'id' =>
'wpCreateaccountMail',
940 'id' =>
'wpPassword2',
941 'placeholder-message' =>
'createacct-yourpassword-ph',
942 'hide-if' => [
'===',
'wpCreateaccountMail',
'1' ],
946 'baseField' =>
'password',
947 'type' =>
'password',
948 'label-message' =>
'createacct-yourpasswordagain',
950 'cssclass' =>
'loginPassword',
952 'validation-callback' =>
function (
$value, $alldata ) {
953 if ( empty( $alldata[
'mailpassword'] ) && !empty( $alldata[
'password'] ) ) {
955 return $this->
msg(
'htmlform-required' );
956 } elseif (
$value !== $alldata[
'password'] ) {
957 return $this->
msg(
'badretype' );
962 'hide-if' => [
'===',
'wpCreateaccountMail',
'1' ],
963 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
967 'label-message' => $wgEmailConfirmToEdit ?
'createacct-emailrequired'
968 :
'createacct-emailoptional',
970 'cssclass' =>
'loginText',
973 'required' => $wgEmailConfirmToEdit,
974 'validation-callback' =>
function (
$value, $alldata ) {
975 global $wgEmailConfirmToEdit;
979 if ( !
$value && $wgEmailConfirmToEdit ) {
982 return $this->
msg(
'noemailtitle' );
983 } elseif ( !
$value && !empty( $alldata[
'mailpassword'] ) ) {
985 return $this->
msg(
'noemailcreate' );
986 } elseif (
$value && !Sanitizer::validateEmail(
$value ) ) {
987 return $this->
msg(
'invalidemailaddress' );
991 'placeholder-message' =>
'createacct-' . $anotherPart .
'email-ph',
995 'help-message' => $isLoggedIn ?
'createacct-another-realname-tip'
996 :
'prefs-help-realname',
997 'label-message' =>
'createacct-realname',
998 'cssclass' =>
'loginText',
1000 'id' =>
'wpRealName',
1005 'label-message' =>
'createacct-reason',
1006 'cssclass' =>
'loginText',
1009 'placeholder-message' =>
'createacct-reason-ph',
1012 'createaccount' => [
1015 'default' => $this->
msg(
'createacct-' . $anotherPart . $continuePart .
1017 'name' =>
'wpCreateaccount',
1018 'id' =>
'wpCreateaccount',
1023 $fieldDefinitions = [
1025 'label-raw' => $this->
msg(
'userlogin-yourname' )->escaped() . $secureLoginLink,
1027 'placeholder-message' =>
'userlogin-yourname-ph',
1030 'id' =>
'wpPassword1',
1031 'placeholder-message' =>
'userlogin-yourpassword-ph',
1038 'name' =>
'wpRemember',
1039 'label-message' => $this->
msg(
'userlogin-remembermypassword' )
1040 ->numParams( $expirationDays ),
1041 'id' =>
'wpRemember',
1046 'default' => $this->
msg(
'pt-login-' . $continuePart .
'button' )->text(),
1047 'id' =>
'wpLoginAttempt',
1050 'linkcontainer' => [
1053 'cssclass' =>
'mw-form-related-link-container mw-userlogin-help',
1058 ->inContentLanguage()
1060 ], $this->
msg(
'userlogin-helplink2' )->
text() ),
1071 $fieldDefinitions[
'username'] += [
1074 'cssclass' =>
'loginText',
1078 $fieldDefinitions[
'password'] += [
1079 'type' =>
'password',
1081 'name' =>
'wpPassword',
1082 'cssclass' =>
'loginPassword',
1093 $fieldDefinitions[
'header'] = [
1100 if ( $this->mEntryError ) {
1101 $fieldDefinitions[
'entryError'] = [
1103 'default' =>
Html::rawElement(
'div', [
'class' => $this->mEntryErrorType .
'box', ],
1104 $this->mEntryError ),
1111 unset( $fieldDefinitions[
'linkcontainer'], $fieldDefinitions[
'signupend'] );
1116 $signupendMsg = $this->
msg(
'signupend' );
1117 $signupendHttpsMsg = $this->
msg(
'signupend-https' );
1118 if ( !$signupendMsg->isDisabled() ) {
1119 $usingHTTPS = $this->
getRequest()->getProtocol() ===
'https';
1120 $signupendText = ( $usingHTTPS && !$signupendHttpsMsg->isBlank() )
1121 ? $signupendHttpsMsg ->parse() : $signupendMsg->parse();
1122 $fieldDefinitions[
'signupend'] = [
1125 'default' =>
Html::rawElement(
'div', [
'id' =>
'signupend' ], $signupendText ),
1132 if ( $passwordReset->isAllowed( $this->getUser() )->isGood() ) {
1133 $fieldDefinitions[
'passwordReset'] = [
1136 'cssclass' =>
'mw-form-related-link-container',
1139 $this->
msg(
'userlogin-resetpassword-link' )->
text()
1151 if ( $this->mLanguage ) {
1154 $loggedIn = $this->
getUser()->isLoggedIn();
1156 $fieldDefinitions[
'createOrLogin'] = [
1159 'linkQuery' => $linkq,
1160 'default' =>
function (
$params )
use ( $loggedIn, $linkTitle ) {
1162 [
'id' =>
'mw-createaccount' . ( !$loggedIn ?
'-cta' :
'' ),
1163 'class' => ( $loggedIn ?
'mw-form-related-link-container' :
'mw-ui-vform-field' ) ],
1164 ( $loggedIn ?
'' : $this->
msg(
'userlogin-noaccount' )->escaped() )
1167 'id' =>
'mw-createaccount-join' . ( $loggedIn ?
'-loggedin' :
'' ),
1168 'href' => $linkTitle->getLocalURL(
$params[
'linkQuery'] ),
1169 'class' => ( $loggedIn ?
'' :
'mw-ui-button' ),
1173 $loggedIn ?
'userlogin-createanother' :
'userlogin-joinproject'
1184 $fieldDefinitions = array_filter( $fieldDefinitions );
1186 return $fieldDefinitions;
1196 if (
$template->get(
'usedomain',
false ) ) {
1198 $fieldDefinitions[
'domain'] = [
1200 'label-message' =>
'yourdomainname',
1201 'options' => array_combine(
$template->get(
'domainnames', [] ),
1203 'default' =>
$template->get(
'domain',
'' ),
1204 'name' =>
'wpDomain',
1210 $extraInputPos = array_search(
'extrainput', array_keys( $fieldDefinitions ),
true );
1211 $fieldDefinitions = array_slice( $fieldDefinitions, 0, $extraInputPos,
true )
1213 + array_slice( $fieldDefinitions, $extraInputPos + 1,
null,
true );
1215 return $fieldDefinitions;
1230 return $wgDisableCookieCheck || (
1242 if ( $this->mReturnTo !==
'' ) {
1243 $returnto =
'returnto=' .
wfUrlencode( $this->mReturnTo );
1244 if ( $this->mReturnToQuery !==
'' ) {
1245 $returnto .=
'&returntoquery=' .
wfUrlencode( $this->mReturnToQuery );
1259 } elseif ( $this->
getUser()->isAllowed(
'createaccount' ) ) {
1267 return $this->
isSignup() ?
'wpCreateaccountToken' :
'wpLoginToken';
1277 $msg = $this->
msg(
'loginlanguagelinks' )->inContentLanguage();
1278 if ( $msg->isBlank() ) {
1281 $langs = explode(
"\n", $msg->text() );
1285 $parts = explode(
'|',
$lang );
1286 if (
count( $parts ) >= 2 ) {
1291 return count( $links ) > 0 ? $this->
msg(
'loginlanguagelabel' )->rawParams(
1292 $this->
getLanguage()->pipeList( $links ) )->escaped() :
'';
1306 return htmlspecialchars( $text );
1309 if ( $this->mReturnTo !==
'' ) {
1316 $attr[
'lang'] = $attr[
'hreflang'] = $targetLanguage->getHtmlCode();
1336 isset( $formDescriptor[
'username'] ) &&
1337 !isset( $formDescriptor[
'username'][
'default'] ) &&
1341 if (
$user->isLoggedIn() ) {
1342 $formDescriptor[
'username'][
'default'] =
$user->getName();
1344 $formDescriptor[
'username'][
'default'] =
1345 $this->
getRequest()->getSession()->suggestLoginUsername();
1352 unset( $formDescriptor[
'createaccount'], $formDescriptor[
'loginattempt'] );
1359 isset( $formDescriptor[
'username'] )
1360 && empty( $formDescriptor[
'username'][
'default'] )
1361 && !$this->
getRequest()->getCheck(
'wpName' )
1363 $formDescriptor[
'username'][
'autofocus'] =
true;
1364 } elseif ( isset( $formDescriptor[
'password'] ) ) {
1365 $formDescriptor[
'password'][
'autofocus'] =
true;
1381 throw new LogicException(
'not used' );
1390 $this->
data[
'extrainput'][] = [
1395 'helptext' => $helptext,
1406 foreach ( $this->
get(
'extrainput', [] )
as $field ) {
1408 'type' => $field[
'type'] ===
'checkbox' ?
'check' : $field[
'type'],
1409 'name' => $field[
'name'],
1410 'value' => $field[
'value'],
1411 'id' => $field[
'name'],
1413 if ( $field[
'msg'] ) {
1414 $definition[
'label-message'] = $this->
getMsg( $field[
'msg'] );
1416 if ( $field[
'helptext'] ) {
1417 $definition[
'help'] = $this->
msgWiki( $field[
'helptext'] );
1422 $name = preg_replace(
'/^wp(?=[A-Z])/',
'', $field[
'name'] );
1423 $definitions[
$name] = $definition;
1426 if ( $this->
haveData(
'extrafields' ) ) {
1427 $definitions[
'extrafields'] = [
1430 'default' => $this->
get(
'extrafields' ),
1434 return $definitions;
1461 self::SUCCESS =>
'success',
1462 self::NO_NAME =>
'no_name',
1463 self::ILLEGAL =>
'illegal',
1464 self::WRONG_PLUGIN_PASS =>
'wrong_plugin_pass',
1465 self::NOT_EXISTS =>
'not_exists',
1466 self::WRONG_PASS =>
'wrong_pass',
1467 self::EMPTY_PASS =>
'empty_pass',
1468 self::RESET_PASS =>
'reset_pass',
1469 self::ABORTED =>
'aborted',
1470 self::CREATE_BLOCKED =>
'create_blocked',
1471 self::THROTTLED =>
'throttled',
1472 self::USER_BLOCKED =>
'user_blocked',
1473 self::NEED_TOKEN =>
'need_token',
1474 self::WRONG_TOKEN =>
'wrong_token',
1475 self::USER_MIGRATED =>
'user_migrated',
1483 parent::__construct();
1510 return is_array(
$res ) ?
true : 0;
1530 return $wgRequest->getSession()->getToken(
'',
'login' )->toString();
1546 $wgRequest->getSession()->resetToken(
'login' );
1555 return $wgRequest->getSession()->getToken(
'',
'createaccount' )->toString();
1571 $wgRequest->getSession()->resetToken(
'createaccount' );
getTokenName()
Returns the name of the CSRF token (under which it should be found in the POST or GET data).
getPageTitle( $subpage=false)
Get a self-referential title object.
setRequest(array $data, $wasPosted=null)
Override the POST data, GET data from the real request is preserved.
msgWiki( $str)
An ugly, ugly hack.
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php For a description of the see design txt $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping $template
error also a ContextSource you ll probably need to make sure the header is varied on $request
postProcessFormDescriptor(&$formDescriptor, $requests)
wfCanIPUseHTTPS( $ip)
Determine whether the client at a given source IP is likely to be able to access the wiki via HTTPS.
addTabIndex(&$formDescriptor)
Adds a sequential tabindex starting from 1 to all form elements.
getExtraInputDefinitions()
Turns addInputItem-style field definitions into HTMLForm field definitions.
getBCFieldDefinitions( $fieldDefinitions, $template)
Adds fields provided via the deprecated UserLoginForm / UserCreateForm hooks.
getOutput()
Get the OutputPage being used for this instance.
if(!isset( $args[0])) $lang
showSuccessPage( $type, $title, $msgname, $injected_html, $extraMessages)
Show the success page.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string & $returnToQuery
showCreateAccountLink()
Whether the login/create account form should display a link to the other form (in addition to whateve...
load( $subPage)
Load data from request.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
makeLanguageSelectorLink( $text, $lang)
Create a language selector link for a particular language Links back to this page preserving type and...
beforeExecute( $subPage)
Gets called before.
static newFatal( $message)
Factory function for fatal errors.
$wgEnableUserEmail
Set to true to enable user-to-user e-mail.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
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,...
getSkin()
Shortcut to get the skin being used for this instance.
Allows to change the fields on the form that will be generated $name
getRequest()
Get the WebRequest object.
getLanguage()
Shortcut to get user's language.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
getName()
Get the name of this Special Page.
A special page subclass for authentication-related special pages.
setSessionUserForCurrentRequest()
Replace some globals to make sure the fact that the user has just been logged in is reflected in the ...
Helper functions for the login form that need to be shared with other special pages (such as CentralA...
getReturnToQueryStringFragment()
Returns a string that can be appended to the URL (without encoding) to preserve the return target.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
trySubmit()
Attempts to do an authentication step with the submitted data.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
B/C class to try handling login/signup template modifications even though login/signup does not actua...
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
string $subPage
Subpage of the special page.
An IContextSource implementation which will inherit context from another source but allow individual ...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
getConfig()
Shortcut to get main config object.
namespace and then decline to actually register it file or subcat img or subcat $title
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
static wrap( $sv)
Succinct helper method to wrap a StatusValue.
logAuthResult( $success, $status=null)
Logs to the authmanager-stats channel.
Holds shared logic for login and account creation pages.
getFullTitle()
Return the full title, including $par.
bool $proxyAccountCreation
True if the user if creating an account for someone else.
loadAuth( $subPage, $authAction=null, $reset=false)
Load or initialize $authAction, $authRequests and $subPage.
mainLoginForm(array $requests, $msg='', $msgtype='error')
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
makeLanguageSelector()
Produce a bar of links which allow the user to select another language during login/registration but ...
when a variable name is used in a it is silently declared as a new masking the global
hasSessionCookie()
Check if a session cookie is present.
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
getContext()
Gets the context this SpecialPage is executed in.
addInputItem( $name, $value, $type, $msg, $helptext=false)
Extensions (AntiSpoof and TitleBlacklist) call this in response to UserCreateForm hook to add checkbo...
getFakeTemplate( $msg, $msgType)
Temporary B/C method to handle extensions using the UserLoginForm/UserCreateForm hooks.
getMsg( $name)
Get a Message object with its context set.
msg()
Wrapper around wfMessage that sets the current context.
static newGood( $value=null)
Factory function for good results.
Parent class for all special pages.
canBypassForm(&$button_name)
Determine if the login form can be bypassed.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getPageHtml( $formHtml)
Add page elements which are outside the form.
static getMain()
Static methods.
FakeAuthTemplate $fakeTemplate
this hook is for auditing only $response
getDefaultAction( $subPage)
Get the default action for this special page, if none is given via URL/POST data.
getContinueAction( $action)
Gets the _CONTINUE version of an action.
execute()
Main function, used by classes that subclass QuickTemplate to show the actual HTML output.
isActionAllowed( $action)
Checks whether AuthManager is ready to perform the action.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
showReturnToPage( $type, $returnTo='', $returnToQuery='', $stickHTTPS=false)
Add a "return to" link or redirect to it.
needsSubmitButton(array $requests)
Returns true if the form built from the given AuthenticationRequests needs a submit button.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
setContext( $context)
Sets the context this SpecialPage is executed in.
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead. & $feedLinks hooks can tweak the array to change how login etc forms should look $requests
getPreservedParams( $withToken=false)
Returns URL query parameters which can be used to reload the page (or leave and return) while preserv...
MediaWiki Logger LoggerFactory implements a PSR[0] compatible message logging system Named Psr Log LoggerInterface instances can be obtained from the MediaWiki Logger LoggerFactory::getInstance() static method. MediaWiki\Logger\LoggerFactory expects a class implementing the MediaWiki\Logger\Spi interface to act as a factory for new Psr\Log\LoggerInterface instances. The "Spi" in MediaWiki\Logger\Spi stands for "service provider interface". An SPI is an API intended to be implemented or extended by a third party. This software design pattern is intended to enable framework extension and replaceable components. It is specifically used in the MediaWiki\Logger\LoggerFactory service to allow alternate PSR-3 logging implementations to be easily integrated with MediaWiki. The service provider interface allows the backend logging library to be implemented in multiple ways. The $wgMWLoggerDefaultSpi global provides the classname of the default MediaWiki\Logger\Spi implementation to be loaded at runtime. This can either be the name of a class implementing the MediaWiki\Logger\Spi with a zero argument const ructor or a callable that will return an MediaWiki\Logger\Spi instance. Alternately the MediaWiki\Logger\LoggerFactory MediaWiki Logger LoggerFactory
isContinued()
Returns true if this is not the first step of the authentication.
loadRequestParameters( $subPage)
Load basic request parameters for this Special page.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
getRequest()
Get the WebRequest being used for this instance.
static factory( $code)
Get a cached or new language object for a given language code.
getToken()
Returns the CSRF token.
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
User $targetUser
FIXME another flag for passing data.
if(! $wgDBerrorLogTZ) $wgRequest
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
successfulAction( $direct=false, $extraMessages=null)
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
Change the form descriptor that determines how a field will look in the authentication form.
An error page which can definitely be safely rendered using the OutputPage.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
this hook is for auditing only or null if authentication failed before getting that far $username
getFieldDefinitions( $template)
Create a HTMLForm descriptor for the core login fields.
Helper class for the password reset functionality shared by the web UI and the API.
static getValidErrorMessages()
Returns an array of all valid error messages.
showExtraInformation()
Show extra information such as password recovery information, link from login to signup,...
New base template for a skin's template extended from QuickTemplate this class features helper method...
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of data
getAuthForm(array $requests, $action, $msg='', $msgType='error')
Generates a form from the given request.
static makeInternalOrExternalUrl( $name)
If url string starts with http, consider as external URL, else internal.
the array() calling protocol came about after MediaWiki 1.4rc1.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect & $returnTo
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out