68 abstract protected function isSignup();
76 abstract protected function successfulAction( $direct =
false, $extraMessages = null );
87 parent::__construct(
$name );
90 $wgUseMediaWikiUIEverywhere =
true;
94 parent::setRequest( $data, $wasPosted );
95 $this->mLoadedRequest =
false;
103 if ( $this->mLoadedRequest ) {
106 $this->mLoadedRequest =
true;
109 $this->mPosted =
$request->wasPosted();
110 $this->mIsReturn =
$subPage ===
'return';
111 $this->mAction =
$request->getVal(
'action' );
112 $this->mFromHTTP =
$request->getBool(
'fromhttp',
false )
113 ||
$request->getBool(
'wpFromhttp',
false );
114 $this->mStickHTTPS = ( !$this->mFromHTTP &&
$request->getProtocol() ===
'https' )
115 ||
$request->getBool(
'wpForceHttps',
false );
116 $this->mLanguage =
$request->getText(
'uselang' );
117 $this->mReturnTo =
$request->getVal(
'returnto',
'' );
118 $this->mReturnToQuery =
$request->getVal(
'returntoquery',
'' );
130 if ( $this->mLoaded ) {
133 $this->mLoaded =
true;
138 $securityLevel && AuthManager::singleton()->securitySensitiveOperationStatus(
149 $entryError = $this->
msg(
$request->getVal(
'error',
'' ) );
150 $entryWarning = $this->
msg(
$request->getVal(
'warning',
'' ) );
155 $this->
msg(
'loginreqlink' )->escaped(),
158 'returnto' => $this->mReturnTo,
159 'returntoquery' => $this->mReturnToQuery,
160 'uselang' => $this->mLanguage,
161 'fromhttp' => $wgSecureLogin && $this->mFromHTTP ?
'1' : null,
166 if ( $entryError->exists()
169 $this->mEntryErrorType =
'error';
170 $this->mEntryError = $entryError->rawParams( $loginreqlink )->parse();
172 } elseif ( $entryWarning->exists()
175 $this->mEntryErrorType =
'warning';
176 $this->mEntryError = $entryWarning->rawParams( $loginreqlink )->parse();
179 # 1. When switching accounts, it sucks to get automatically logged out
180 # 2. Do not return to PasswordReset after a successful password change
181 # but goto Wiki start page (Main_Page) instead ( bug 33997 )
183 if ( is_object( $returnToTitle )
184 && ( $returnToTitle->isSpecial(
'Userlogout' )
185 || $returnToTitle->isSpecial(
'PasswordReset' ) )
187 $this->mReturnTo =
'';
188 $this->mReturnToQuery =
'';
195 $params = parent::getPreservedParams( $withToken );
197 'returnto' => $this->mReturnTo ?: null,
198 'returntoquery' => $this->mReturnToQuery ?: null,
200 if ( $wgSecureLogin && !$this->
isSignup() ) {
201 $params[
'fromhttp'] = $this->mFromHTTP ?
'1' : null;
209 return parent::beforeExecute(
$subPage );
216 $authManager = AuthManager::singleton();
217 $session = SessionManager::getGlobalSession();
228 if ( !$this->
isSignup() && !$session->canSetUser() ) {
229 throw new ErrorPageError(
'cannotloginnow-title',
'cannotloginnow-text', [
248 if ( !$this->
isSignup() && !$this->mPosted && !$this->securityLevel &&
249 ( $this->mReturnTo !==
'' || $this->mReturnToQuery !==
'' ) &&
257 if ( $this->
getRequest()->getProtocol() !==
'https' ) {
261 ( $this->mEntryErrorType ===
'error' ?
'error'
262 :
'warning' ) => $this->mEntryError,
265 if ( $wgSecureLogin && !$this->mFromHTTP &&
272 $this->
getOutput()->addVaryHeader(
'X-Forwarded-Proto' );
279 if ( substr( $url, 0, 8 ) ===
'https://' ) {
280 $this->mSecureLoginUrl = $url;
289 $this->
mainLoginForm( [],
'authpage-cannot-' . $this->authAction );
296 if ( $button_name ) {
297 $this->
getRequest()->setVal( $button_name,
true );
314 case AuthenticationResponse::PASS:
316 $this->proxyAccountCreation = $this->
isSignup() && !$this->
getUser()->isAnon();
320 !$this->proxyAccountCreation
322 && $authManager->canAuthenticateNow()
325 $response2 = $authManager->beginAuthentication( [
$response->loginRequest ],
327 if ( $response2->status !== AuthenticationResponse::PASS ) {
328 LoggerFactory::getInstance(
'login' )
329 ->error(
'Could not log in after account creation' );
335 if ( !$this->proxyAccountCreation ) {
342 case AuthenticationResponse::FAIL:
344 case AuthenticationResponse::RESTART:
345 unset( $this->authForm );
346 if (
$response->status === AuthenticationResponse::FAIL ) {
348 $messageType =
'error';
351 $messageType =
'warning';
357 case AuthenticationResponse::REDIRECT:
358 unset( $this->authForm );
361 case AuthenticationResponse::UI:
362 unset( $this->authForm );
363 $this->authAction = $this->
isSignup() ? AuthManager::ACTION_CREATE_CONTINUE
364 : AuthManager::ACTION_LOGIN_CONTINUE;
365 $this->authRequests =
$response->neededRequests;
391 $fields = AuthenticationRequest::mergeFieldInfo( $this->authRequests );
392 foreach ( $fields
as $fieldname => $field ) {
393 if ( !isset( $field[
'type'] ) ) {
396 if ( !empty( $field[
'skippable'] ) ) {
399 if ( $field[
'type'] ===
'button' ) {
400 if ( $button_name !== null ) {
404 $button_name = $fieldname;
406 } elseif ( $field[
'type'] !==
'null' ) {
423 $type,
$title, $msgname, $injected_html, $extraMessages
430 if ( $extraMessages ) {
432 $out->addWikiText( $extraMessages->getWikiText() );
435 $out->addHTML( $injected_html );
438 $helper->showReturnToPage(
$type, $this->mReturnTo, $this->mReturnToQuery, $this->mStickHTTPS );
512 $this->authForm = null;
513 $requests = AuthManager::singleton()->getAuthenticationRequests( $this->authAction,
$user );
517 $out->addModuleStyles( [
519 'mediawiki.ui.button',
520 'mediawiki.ui.checkbox',
521 'mediawiki.ui.input',
522 'mediawiki.special.userlogin.common.styles'
526 $out->addJsConfigVars(
'wgCreateacctImgcaptchaHelp',
527 $this->
msg(
'createacct-imgcaptcha-help' )->parse() );
531 'mediawiki.special.userlogin.signup.js'
533 $out->addModuleStyles( [
534 'mediawiki.special.userlogin.signup.styles'
538 $out->addModuleStyles( [
539 'mediawiki.special.userlogin.login.styles'
542 $out->disallowUserJs();
544 $form = $this->
getAuthForm( $requests, $this->authAction, $msg, $msgtype );
545 $form->prepareForm();
561 [
'id' =>
'userloginprompt' ], $this->
msg(
'loginprompt' )->parseAsBlock() );
563 $signupStartMsg = $this->
msg(
'signupstart' );
564 $signupStart = ( $this->
isSignup() && !$signupStartMsg->isDisabled() )
565 ?
Html::rawElement(
'div', [
'id' =>
'signupstart' ], $signupStartMsg->parseAsBlock() ) :
'';
566 if ( $languageLinks ) {
572 $benefitsContainer =
'';
580 for ( $benefitIdx = 1; $benefitIdx <= $benefitCount; $benefitIdx++ ) {
581 $headUnescaped = $this->
msg(
"createacct-benefit-head$benefitIdx" )->text();
582 $iconClass = $this->
msg(
"createacct-benefit-icon$benefitIdx" )->escaped();
583 $benefitList .=
Html::rawElement(
'div', [
'class' =>
"mw-number-text $iconClass" ],
585 $this->
msg(
"createacct-benefit-head$benefitIdx" )->escaped()
588 $this->
msg(
"createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped()
592 $benefitsContainer =
Html::rawElement(
'div', [
'class' =>
'mw-createacct-benefits-container' ],
625 if ( isset( $this->authForm ) ) {
629 $usingHTTPS = $this->
getRequest()->getProtocol() ===
'https';
632 $fieldInfo = AuthenticationRequest::mergeFieldInfo( $requests );
636 $formDescriptor = static::fieldInfoToFormDescriptor( $requests, $fieldInfo, $this->authAction );
647 $form->addHiddenField(
'authAction', $this->authAction );
648 if ( $wgLoginLanguageSelector ) {
649 $form->addHiddenField(
'uselang', $this->mLanguage );
651 $form->addHiddenField(
'force', $this->securityLevel );
653 if ( $wgSecureLogin ) {
656 $form->addHiddenField(
'wpForceHttps', (
int)$this->mStickHTTPS );
657 $form->addHiddenField(
'wpFromhttp', $usingHTTPS );
663 $form->setName(
'userlogin' . ( $this->
isSignup() ?
'2' :
'' ) );
665 $form->setId(
'userlogin2' );
678 $statusAreaAttribs = [
'id' =>
'mw-createacct-status-area' ];
680 $form->addHeaderText(
Html::element(
'div', $statusAreaAttribs ) );
689 $signupendMsg = $this->
msg(
'signupend' );
690 $signupendHttpsMsg = $this->
msg(
'signupend-https' );
691 if ( !$signupendMsg->isDisabled() ) {
692 $signupendText = ( $usingHTTPS && !$signupendHttpsMsg->isBlank() )
693 ? $signupendHttpsMsg ->parse() : $signupendMsg->parse();
694 $form->addPostText(
Html::rawElement(
'div', [
'id' =>
'signupend' ], $signupendText ) );
700 $reauthMessage = $this->securityLevel ?
'userlogin-reauth' :
'userlogin-loggedin';
702 $this->
msg( $reauthMessage )->params( $this->
getUser()->
getName() )->parse() ) );
707 if ( $passwordReset->isAllowed( $this->getUser() ) ) {
710 [
'class' =>
'mw-ui-vform-field mw-form-related-link-container' ],
713 $this->
msg(
'userlogin-resetpassword-link' )->escaped()
724 if ( $wgLoginLanguageSelector && $this->mLanguage ) {
727 $createOrLoginHref = $linkTitle->getLocalURL( $linkq );
729 if ( $this->
getUser()->isLoggedIn() ) {
731 [
'class' =>
'mw-ui-vform-field' ],
734 'id' =>
'mw-createaccount-join',
735 'href' => $createOrLoginHref,
739 $this->
msg(
'userlogin-createanother' )->escaped()
744 [
'id' =>
'mw-createaccount-cta',
745 'class' =>
'mw-ui-vform-field' ],
746 $this->
msg(
'userlogin-noaccount' )->escaped()
749 'id' =>
'mw-createaccount-join',
750 'href' => $createOrLoginHref,
751 'class' =>
'mw-ui-button',
754 $this->
msg(
'userlogin-joinproject' )->escaped()
758 $form->addFooterText( $createOrLoginHtml );
762 $form->suppressDefaultSubmit();
764 $this->authForm = $form;
783 'mUsername' =>
$request->getText(
'wpName' ),
784 'mPassword' =>
$request->getText(
'wpPassword' ),
785 'mRetype' =>
$request->getText(
'wpRetype' ),
786 'mEmail' =>
$request->getText(
'wpEmail' ),
787 'mRealName' =>
$request->getText(
'wpRealName' ),
788 'mDomain' =>
$request->getText(
'wpDomain' ),
789 'mReason' =>
$request->getText(
'wpReason' ),
790 'mRemember' =>
$request->getCheck(
'wpRemember' ),
803 if ( $data->mUsername ==
'' && $this->isSignup() ) {
804 if (
$user->isLoggedIn() ) {
805 $data->mUsername =
$user->getName();
807 $data->mUsername = $this->
getRequest()->getSession()->suggestLoginUsername();
815 $q =
'action=submitlogin&type=signup';
816 $linkq =
'type=login';
818 $q =
'action=submitlogin&type=login';
819 $linkq =
'type=signup';
822 if ( $this->mReturnTo !==
'' ) {
823 $returnto =
'&returnto=' .
wfUrlencode( $this->mReturnTo );
824 if ( $this->mReturnToQuery !==
'' ) {
825 $returnto .=
'&returntoquery=' .
832 # Don't show a "create account" link if the user can't.
834 # Pass any language selection on to the mode switch link
835 if ( $wgLoginLanguageSelector && $this->mLanguage ) {
839 $template->set(
'createOrLoginHref', $titleObj->getLocalURL( $linkq ) );
846 : is_array( $wgPasswordResetRoutes )
847 && in_array(
true, array_values( $wgPasswordResetRoutes ),
true );
853 $template->set(
'name', $data->mUsername );
854 $template->set(
'password', $data->mPassword );
855 $template->set(
'retype', $data->mRetype );
856 $template->set(
'createemailset',
false );
857 $template->set(
'email', $data->mEmail );
858 $template->set(
'realname', $data->mRealName );
859 $template->set(
'domain', $data->mDomain );
860 $template->set(
'reason', $data->mReason );
861 $template->set(
'remember', $data->mRemember );
863 $template->set(
'action', $titleObj->getLocalURL( $q ) );
865 $template->set(
'messagetype', $msgType );
866 $template->set(
'createemail', $wgEnableEmail &&
$user->isLoggedIn() );
867 $template->set(
'userealname', !in_array(
'realname', $wgHiddenPrefs,
true ) );
868 $template->set(
'useemail', $wgEnableEmail );
869 $template->set(
'emailrequired', $wgEmailConfirmToEdit );
870 $template->set(
'emailothers', $wgEnableUserEmail );
871 $template->set(
'canreset', $wgAuth->allowPasswordChange() );
872 $template->set(
'resetlink', $resetLink );
874 ->getRememberUserDuration() !== null );
876 $template->set(
'cansecurelogin', ( $wgSecureLogin ) );
877 $template->set(
'stickhttps', (
int)$this->mStickHTTPS );
882 $action = $this->
isSignup() ?
'signup' :
'login';
883 $wgAuth->modifyUITemplate(
$template, $action );
886 $hookName = $this->
isSignup() ?
'UserCreateForm' :
'UserLoginForm';
900 $specialFields = array_merge( [
'extraInput',
'linkcontainer',
'entryError' ],
901 array_keys( $this->fakeTemplate->getExtraInputDefinitions() ) );
904 foreach ( $coreFieldDescriptors
as $fieldName => $coreField ) {
905 $requestField = isset( $formDescriptor[$fieldName] ) ?
906 $formDescriptor[$fieldName] : [];
911 !isset( $fieldInfo[$fieldName] )
913 !isset( $coreField[
'baseField'] )
914 || !isset( $fieldInfo[$coreField[
'baseField']] )
915 ) && !in_array( $fieldName, $specialFields,
true )
916 && ( !isset( $coreField[
'type'] ) || $coreField[
'type'] !==
'submit' )
918 $coreFieldDescriptors[$fieldName] = null;
924 isset( $coreField[
'label'] )
925 || isset( $coreField[
'label-message'] )
926 || isset( $coreField[
'label-raw'] )
928 unset( $requestField[
'label'], $requestField[
'label-message'], $coreField[
'label-raw'] );
931 $coreFieldDescriptors[$fieldName] += $requestField;
934 $formDescriptor = array_filter( $coreFieldDescriptors + $formDescriptor );
955 global $wgEmailConfirmToEdit;
957 $isLoggedIn = $this->
getUser()->isLoggedIn();
958 $continuePart = $this->
isContinued() ?
'continue-' :
'';
959 $anotherPart = $isLoggedIn ?
'another-' :
'';
960 $expiration = $this->
getRequest()->getSession()->getProvider()
961 ->getRememberUserDuration();
962 $expirationDays = ceil( $expiration / ( 3600 * 24 ) );
963 $secureLoginLink =
'';
964 if ( $this->mSecureLoginUrl ) {
966 'href' => $this->mSecureLoginUrl,
967 'class' =>
'mw-ui-flush-right mw-secure',
968 ], $this->
msg(
'userlogin-signwithsecure' )->
text() );
972 $fieldDefinitions = [
974 'label-message' =>
'userlogin-yourname',
976 'help-message' =>
'createacct-helpusername',
978 'placeholder-message' => $isLoggedIn ?
'createacct-another-username-ph'
979 :
'userlogin-yourname-ph',
984 'label-message' =>
'createaccountmail',
985 'name' =>
'wpCreateaccountMail',
986 'id' =>
'wpCreateaccountMail',
989 'id' =>
'wpPassword2',
990 'placeholder-message' =>
'createacct-yourpassword-ph',
991 'hide-if' => [
'===',
'wpCreateaccountMail',
'1' ],
995 'baseField' =>
'password',
996 'type' =>
'password',
997 'label-message' =>
'createacct-yourpasswordagain',
999 'cssclass' =>
'loginPassword',
1001 'validation-callback' =>
function (
$value, $alldata ) {
1002 if ( empty( $alldata[
'mailpassword'] ) && !empty( $alldata[
'password'] ) ) {
1004 return $this->
msg(
'htmlform-required' );
1005 } elseif (
$value !== $alldata[
'password'] ) {
1006 return $this->
msg(
'badretype' );
1011 'hide-if' => [
'===',
'wpCreateaccountMail',
'1' ],
1012 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
1016 'label-message' => $wgEmailConfirmToEdit ?
'createacct-emailrequired'
1017 :
'createacct-emailoptional',
1019 'cssclass' =>
'loginText',
1022 'required' => $wgEmailConfirmToEdit,
1023 'validation-callback' =>
function (
$value, $alldata ) {
1024 global $wgEmailConfirmToEdit;
1028 if ( !
$value && $wgEmailConfirmToEdit ) {
1031 return $this->
msg(
'noemailtitle' );
1032 } elseif ( !
$value && !empty( $alldata[
'mailpassword'] ) ) {
1034 return $this->
msg(
'noemailcreate' );
1036 return $this->
msg(
'invalidemailaddress' );
1040 'placeholder-message' =>
'createacct-' . $anotherPart .
'email-ph',
1044 'help-message' => $isLoggedIn ?
'createacct-another-realname-tip'
1045 :
'prefs-help-realname',
1046 'label-message' =>
'createacct-realname',
1047 'cssclass' =>
'loginText',
1049 'id' =>
'wpRealName',
1054 'label-message' =>
'createacct-reason',
1055 'cssclass' =>
'loginText',
1058 'placeholder-message' =>
'createacct-reason-ph',
1061 'createaccount' => [
1064 'default' => $this->
msg(
'createacct-' . $anotherPart . $continuePart .
1066 'name' =>
'wpCreateaccount',
1067 'id' =>
'wpCreateaccount',
1072 $fieldDefinitions = [
1074 'label-raw' => $this->
msg(
'userlogin-yourname' )->escaped() . $secureLoginLink,
1076 'placeholder-message' =>
'userlogin-yourname-ph',
1079 'id' =>
'wpPassword1',
1080 'placeholder-message' =>
'userlogin-yourpassword-ph',
1087 'name' =>
'wpRemember',
1088 'label-message' => $this->
msg(
'userlogin-remembermypassword' )
1089 ->numParams( $expirationDays ),
1090 'id' =>
'wpRemember',
1095 'default' => $this->
msg(
'pt-login-' . $continuePart .
'button' )->text(),
1096 'id' =>
'wpLoginAttempt',
1099 'linkcontainer' => [
1102 'cssclass' =>
'mw-form-related-link-container mw-userlogin-help',
1107 ->inContentLanguage()
1109 ], $this->
msg(
'userlogin-helplink2' )->
text() ),
1119 $fieldDefinitions[
'username'] += [
1122 'cssclass' =>
'loginText',
1126 $fieldDefinitions[
'password'] += [
1127 'type' =>
'password',
1129 'name' =>
'wpPassword',
1130 'cssclass' =>
'loginPassword',
1135 if ( $this->mEntryError ) {
1136 $fieldDefinitions[
'entryError'] = [
1138 'default' =>
Html::rawElement(
'div', [
'class' => $this->mEntryErrorType .
'box', ],
1139 $this->mEntryError ),
1147 unset( $fieldDefinitions[
'linkcontainer'] );
1151 $fieldDefinitions = array_filter( $fieldDefinitions );
1153 return $fieldDefinitions;
1163 if (
$template->get(
'usedomain',
false ) ) {
1165 $fieldDefinitions[
'domain'] = [
1167 'label-message' =>
'yourdomainname',
1168 'options' => array_combine(
$template->get(
'domainnames', [] ),
1170 'default' =>
$template->get(
'domain',
'' ),
1171 'name' =>
'wpDomain',
1177 $extraInputPos = array_search(
'extrainput', array_keys( $fieldDefinitions ),
true );
1178 $fieldDefinitions = array_slice( $fieldDefinitions, 0, $extraInputPos,
true )
1180 + array_slice( $fieldDefinitions, $extraInputPos + 1, null,
true );
1182 return $fieldDefinitions;
1197 return $wgDisableCookieCheck || (
1198 $wgInitialSessionId &&
1209 if ( $this->mReturnTo !==
'' ) {
1210 $returnto =
'returnto=' .
wfUrlencode( $this->mReturnTo );
1211 if ( $this->mReturnToQuery !==
'' ) {
1212 $returnto .=
'&returntoquery=' .
wfUrlencode( $this->mReturnToQuery );
1226 } elseif ( $this->
getUser()->isAllowed(
'createaccount' ) ) {
1234 return $this->
isSignup() ?
'wpCreateaccountToken' :
'wpLoginToken';
1244 $msg = $this->
msg(
'loginlanguagelinks' )->inContentLanguage();
1245 if ( $msg->isBlank() ) {
1248 $langs = explode(
"\n", $msg->text() );
1251 $lang = trim( $lang,
'* ' );
1252 $parts = explode(
'|', $lang );
1253 if ( count( $parts ) >= 2 ) {
1258 return count( $links ) > 0 ? $this->
msg(
'loginlanguagelabel' )->rawParams(
1259 $this->
getLanguage()->pipeList( $links ) )->escaped() :
'';
1273 return htmlspecialchars( $text );
1276 if ( $this->mReturnTo !==
'' ) {
1283 $attr[
'lang'] = $attr[
'hreflang'] = $targetLanguage->getHtmlCode();
1287 htmlspecialchars( $text ),
1303 isset( $formDescriptor[
'username'] ) &&
1304 !isset( $formDescriptor[
'username'][
'default'] ) &&
1308 if (
$user->isLoggedIn() ) {
1309 $formDescriptor[
'username'][
'default'] =
$user->getName();
1311 $formDescriptor[
'username'][
'default'] =
1312 $this->
getRequest()->getSession()->suggestLoginUsername();
1319 unset( $formDescriptor[
'createaccount'], $formDescriptor[
'loginattempt'] );
1326 isset( $formDescriptor[
'username'] )
1327 && empty( $formDescriptor[
'username'][
'default'] )
1328 && !$this->
getRequest()->getCheck(
'wpName' )
1330 $formDescriptor[
'username'][
'autofocus'] =
true;
1331 } elseif ( isset( $formDescriptor[
'password'] ) ) {
1332 $formDescriptor[
'password'][
'autofocus'] =
true;
1357 $this->
data[
'extrainput'][] = [
1362 'helptext' => $helptext,
1373 foreach ( $this->
get(
'extrainput', [] )
as $field ) {
1375 'type' => $field[
'type'] ===
'checkbox' ?
'check' : $field[
'type'],
1376 'name' => $field[
'name'],
1377 'value' => $field[
'value'],
1378 'id' => $field[
'name'],
1380 if ( $field[
'msg'] ) {
1381 $definition[
'label-message'] = $this->
getMsg( $field[
'msg'] );
1383 if ( $field[
'helptext'] ) {
1384 $definition[
'help'] = $this->
msgWiki( $field[
'helptext'] );
1389 $name = preg_replace(
'/^wp(?=[A-Z])/',
'', $field[
'name'] );
1390 $definitions[
$name] = $definition;
1393 if ( $this->
haveData(
'extrafields' ) ) {
1394 $definitions[
'extrafields'] = [
1397 'default' => $this->
get(
'extrafields' ),
1401 return $definitions;
1428 self::SUCCESS =>
'success',
1429 self::NO_NAME =>
'no_name',
1430 self::ILLEGAL =>
'illegal',
1431 self::WRONG_PLUGIN_PASS =>
'wrong_plugin_pass',
1432 self::NOT_EXISTS =>
'not_exists',
1434 self::EMPTY_PASS =>
'empty_pass',
1435 self::RESET_PASS =>
'reset_pass',
1436 self::ABORTED =>
'aborted',
1437 self::CREATE_BLOCKED =>
'create_blocked',
1438 self::THROTTLED =>
'throttled',
1439 self::USER_BLOCKED =>
'user_blocked',
1440 self::NEED_TOKEN =>
'need_token',
1441 self::WRONG_TOKEN =>
'wrong_token',
1442 self::USER_MIGRATED =>
'user_migrated',
1450 parent::__construct();
1468 return $throttler->increase(
$username, $wgRequest->getIP(), __METHOD__ );
1477 return is_array(
$res ) ?
true : 0;
1488 return $throttler->clear(
$username, $wgRequest->getIP() );
1497 return $wgRequest->getSession()->getToken(
'',
'login' )->toString();
1513 $wgRequest->getSession()->resetToken(
'login' );
1522 return $wgRequest->getSession()->getToken(
'',
'createaccount' )->toString();
1538 $wgRequest->getSession()->resetToken(
'createaccount' );
static newFromName($name, $validate= 'valid')
Static factory method for creation from username.
setSessionUserForCurrentRequest()
Replace some globals to make sure the fact that the user has just been logged in is reflected in the ...
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
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
FakeAuthTemplate $fakeTemplate
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
the array() calling protocol came about after MediaWiki 1.4rc1.
getAuthForm(array $requests, $action, $msg= '', $msgType= 'error')
Generates a form from the given request.
null for the local 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
wfCanIPUseHTTPS($ip)
Determine whether the client at a given source IP is likely to be able to access the wiki via HTTPS...
static wrap($sv)
Succinct helper method to wrap a StatusValue.
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
A special page subclass for authentication-related special pages.
getContext()
Gets the context this SpecialPage is executed in.
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 one of or reset 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
makeLanguageSelectorLink($text, $lang)
Create a language selector link for a particular language Links back to this page preserving type and...
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name.
static getCanonicalName($name, $validate= 'valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid...
getFakeTemplate($msg, $msgType)
Temporary B/C method to handle extensions using the UserLoginForm/UserCreateForm hooks.
needsSubmitButton(array $requests)
Returns true if the form built from the given AuthenticationRequests needs a submit button...
makeLanguageSelector()
Produce a bar of links which allow the user to select another language during login/registration but ...
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
if(!isset($args[0])) $lang
An IContextSource implementation which will inherit context from another source but allow individual ...
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
New base template for a skin's template extended from QuickTemplate this class features helper method...
getToken()
Returns the CSRF token.
mainLoginForm(array $requests, $msg= '', $msgtype= 'error')
msg()
Wrapper around wfMessage that sets the current context.
User $targetUser
FIXME another flag for passing data.
get($name, $default=null)
Gets the template data requested.
getOutput()
Get the OutputPage being used for this instance.
wfUrlencode($s)
We want some things to be included as literal characters in our title URLs for prettiness, which urlencode encodes by default.
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 $response
when a variable name is used in a it is silently declared as a new local masking the global
Holds shared logic for login and account creation pages.
static newFatal($message)
Factory function for fatal errors.
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
showExtraInformation()
Show extra information such as password recovery information, link from login to signup, CTA etc? Such information should only be shown on the "landing page", ie.
$wgEnableEmail
Set to true to enable the e-mail basic features: Password reminders, etc.
showSuccessPage($type, $title, $msgname, $injected_html, $extraMessages)
Show the success page.
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
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
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
$wgLoginLanguageSelector
Show a bar of language selection links in the user login and user registration forms; edit the "login...
isActionAllowed($action)
Checks whether AuthManager is ready to perform the action.
Parent class for all special pages.
isContinued()
Returns true if this is not the first step of the authentication.
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
getContinueAction($action)
Gets the _CONTINUE version of an action.
static getMain()
Static methods.
canBypassForm(&$button_name)
Determine if the login form can be bypassed.
getMsg($name)
Get a Message object with its context set.
logAuthResult($success, $status=null)
Logs to the authmanager-stats channel.
addTabIndex(&$formDescriptor)
Adds a sequential tabindex starting from 1 to all form elements.
getExtraInputDefinitions()
Turns addInputItem-style field definitions into HTMLForm field definitions.
wfAppendQuery($url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
An error page which can definitely be safely rendered using the OutputPage.
loadRequestParameters($subPage)
Load basic request parameters for this Special page.
getBCFieldDefinitions($fieldDefinitions, $template)
Adds fields provided via the deprecated UserLoginForm / UserCreateForm hooks.
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 after processing 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 unsetoffset-wrap String Wrap the message in html(usually something like"<
B/C class to try handling login/signup template modifications even though login/signup does not actua...
getSkin()
Shortcut to get the skin being used for this instance.
wfDeprecated($function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
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
namespace and then decline to actually register it file or subcat img or subcat $title
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
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
$wgEnableUserEmail
Set to true to enable user-to-user e-mail.
Helper functions for the login form that need to be shared with other special pages (such as CentralA...
getFieldDefinitions($template)
Create a HTMLForm descriptor for the core login fields.
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
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
loadAuth($subPage, $authAction=null, $reset=false)
Load or initialize $authAction, $authRequests and $subPage.
Helper class for the password reset functionality shared by the web UI and the API.
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 local account $user
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
setRequest(array $data, $wasPosted=null)
showReturnToPage($type, $returnTo= '', $returnToQuery= '', $stickHTTPS=false)
Add a "return to" link or redirect to it.
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
this hook is for auditing only or null if authentication failed before getting that far $username
error also a ContextSource you ll probably need to make sure the header is varied on $request
getName()
Get the name of this Special Page.
bool $proxyAccountCreation
True if the user if creating an account for someone else.
getPageHtml($formHtml)
Add page elements which are outside the form.
getDefaultAction($subPage)
Get the default action for this special page, if none is given via URL/POST data. ...
getUser()
Shortcut to get the User executing this instance.
getConfig()
Shortcut to get main config object.
this hook is for auditing only WRONG_PASS
static getValidErrorMessages()
Returns an array of all valid error messages.
getLanguage()
Shortcut to get user's language.
load($subPage)
Load data from request.
postProcessFormDescriptor(&$formDescriptor, $requests)
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
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
static makeInternalOrExternalUrl($name)
If url string starts with http, consider as external URL, else internal.
getFullTitle()
Return the full title, including $par.
static validateEmail($addr)
Does a string look like an e-mail address?
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
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 one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect & $returnTo
static factory($code)
Get a cached or new language object for a given language code.
showCreateAccountLink()
Whether the login/create account form should display a link to the other form (in addition to whateve...
string $subPage
Subpage of the special page.
getPreservedParams($withToken=false)
static element($element, $attribs=[], $contents= '')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
successfulAction($direct=false, $extraMessages=null)
setContext($context)
Sets the context this SpecialPage is executed in.
if(is_null($wgLocalTZoffset)) if(!$wgDBerrorLogTZ) $wgRequest
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 one of or reset 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
getReturnToQueryStringFragment()
Returns a string that can be appended to the URL (without encoding) to preserve the return target...
addInputItem($name, $value, $type, $msg, $helptext=false)
Extensions (AntiSpoof and TitleBlacklist) call this in response to UserCreateForm hook to add checkbo...
getPageTitle($subpage=false)
Get a self-referential title object.
Allows to change the fields on the form that will be generated $name
trySubmit()
Attempts to do an authentication step with the submitted data.