Go to the documentation of this file.
31 use Wikimedia\ScopedCallback;
69 abstract protected function isSignup();
77 abstract protected function successfulAction( $direct =
false, $extraMessages =
null );
88 parent::__construct(
$name );
95 parent::setRequest( $data, $wasPosted );
96 $this->mLoadedRequest =
false;
104 if ( $this->mLoadedRequest ) {
107 $this->mLoadedRequest =
true;
110 $this->mPosted =
$request->wasPosted();
111 $this->mIsReturn =
$subPage ===
'return';
112 $this->mAction =
$request->getVal(
'action' );
113 $this->mFromHTTP =
$request->getBool(
'fromhttp',
false )
114 ||
$request->getBool(
'wpFromhttp',
false );
115 $this->mStickHTTPS = ( !$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',
'' );
131 if ( $this->mLoaded ) {
134 $this->mLoaded =
true;
139 $securityLevel && AuthManager::singleton()->securitySensitiveOperationStatus(
150 $entryError = $this->
msg(
$request->getVal(
'error',
'' ) );
151 $entryWarning = $this->
msg(
$request->getVal(
'warning',
'' ) );
156 $this->
msg(
'loginreqlink' )->
text(),
159 'returnto' => $this->mReturnTo,
160 'returntoquery' => $this->mReturnToQuery,
161 'uselang' => $this->mLanguage ?:
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 =
'';
196 $params = parent::getPreservedParams( $withToken );
198 'returnto' => $this->mReturnTo ?:
null,
199 'returntoquery' => $this->mReturnToQuery ?:
null,
202 $params[
'fromhttp'] = $this->mFromHTTP ?
'1' :
null;
210 return parent::beforeExecute(
$subPage );
217 if ( $this->mPosted ) {
218 $time = microtime(
true );
219 $profilingScope =
new ScopedCallback(
function ()
use (
$time ) {
221 $statsd = MediaWikiServices::getInstance()->getStatsdDataFactory();
222 $statsd->timing(
"timing.login.ui.{$this->authAction}",
$time * 1000 );
226 $authManager = AuthManager::singleton();
227 $session = SessionManager::getGlobalSession();
238 if ( !$this->
isSignup() && !$authManager->canAuthenticateNow() ) {
239 if ( !$session->canSetUser() ) {
240 throw new ErrorPageError(
'cannotloginnow-title',
'cannotloginnow-text', [
244 throw new ErrorPageError(
'cannotlogin-title',
'cannotlogin-text' );
245 } elseif ( $this->
isSignup() && !$authManager->canCreateAccounts() ) {
246 throw new ErrorPageError(
'cannotcreateaccount-title',
'cannotcreateaccount-text' );
263 if ( !$this->
isSignup() && !$this->mPosted && !$this->securityLevel &&
264 ( $this->mReturnTo !==
'' || $this->mReturnToQuery !==
'' ) &&
273 if ( $this->
getRequest()->getProtocol() !==
'https' ) {
277 ( $this->mEntryErrorType ===
'error' ?
'error'
278 :
'warning' ) => $this->mEntryError,
288 $this->
getOutput()->addVaryHeader(
'X-Forwarded-Proto' );
295 if ( substr( $url, 0, 8 ) ===
'https://' ) {
296 $this->mSecureLoginUrl = $url;
305 $this->
mainLoginForm( [],
'authpage-cannot-' . $this->authAction );
312 if ( $button_name ) {
313 $this->
getRequest()->setVal( $button_name,
true );
330 case AuthenticationResponse::PASS:
332 $this->proxyAccountCreation = $this->
isSignup() && !$this->
getUser()->isAnon();
336 !$this->proxyAccountCreation
338 && $authManager->canAuthenticateNow()
341 $response2 = $authManager->beginAuthentication( [
$response->loginRequest ],
343 if ( $response2->status !== AuthenticationResponse::PASS ) {
344 LoggerFactory::getInstance(
'login' )
345 ->error(
'Could not log in after account creation' );
351 if ( !$this->proxyAccountCreation ) {
358 case AuthenticationResponse::FAIL:
360 case AuthenticationResponse::RESTART:
361 unset( $this->authForm );
362 if (
$response->status === AuthenticationResponse::FAIL ) {
364 $messageType =
'error';
367 $messageType =
'warning';
373 case AuthenticationResponse::REDIRECT:
374 unset( $this->authForm );
377 case AuthenticationResponse::UI:
378 unset( $this->authForm );
379 $this->authAction = $this->
isSignup() ? AuthManager::ACTION_CREATE_CONTINUE
380 : AuthManager::ACTION_LOGIN_CONTINUE;
381 $this->authRequests =
$response->neededRequests;
385 throw new LogicException(
'invalid AuthenticationResponse' );
407 $fields = AuthenticationRequest::mergeFieldInfo( $this->authRequests );
408 foreach ( $fields
as $fieldname => $field ) {
409 if ( !isset( $field[
'type'] ) ) {
412 if ( !empty( $field[
'skippable'] ) ) {
415 if ( $field[
'type'] ===
'button' ) {
416 if ( $button_name !==
null ) {
420 $button_name = $fieldname;
422 } elseif ( $field[
'type'] !==
'null' ) {
439 $type,
$title, $msgname, $injected_html, $extraMessages
446 if ( $extraMessages ) {
448 $out->addWikiText( $extraMessages->getWikiText() );
451 $out->addHTML( $injected_html );
454 $helper->showReturnToPage(
$type, $this->mReturnTo, $this->mReturnToQuery, $this->mStickHTTPS );
473 $type, $returnTo =
'', $returnToQuery =
'', $stickHTTPS =
false
476 $helper->showReturnToPage(
$type, $returnTo, $returnToQuery, $stickHTTPS );
523 $this->authForm =
null;
524 $requests = AuthManager::singleton()->getAuthenticationRequests( $this->authAction,
$user );
528 $out->addModuleStyles( [
530 'mediawiki.ui.button',
531 'mediawiki.ui.checkbox',
532 'mediawiki.ui.input',
533 'mediawiki.special.userlogin.common.styles'
537 $out->addJsConfigVars(
'wgCreateacctImgcaptchaHelp',
538 $this->
msg(
'createacct-imgcaptcha-help' )->parse() );
542 'mediawiki.special.userlogin.signup.js'
544 $out->addModuleStyles( [
545 'mediawiki.special.userlogin.signup.styles'
549 $out->addModuleStyles( [
550 'mediawiki.special.userlogin.login.styles'
553 $out->disallowUserJs();
555 $form = $this->
getAuthForm( $requests, $this->authAction, $msg, $msgtype );
556 $form->prepareForm();
559 if ( $msg && $msgtype ===
'warning' ) {
560 $submitStatus->warning( $msg );
561 } elseif ( $msg && $msgtype ===
'error' ) {
562 $submitStatus->fatal( $msg );
568 $this->
getUser()->isLoggedIn() &&
569 $this->authAction !== AuthManager::ACTION_LOGIN_CONTINUE
571 $reauthMessage = $this->securityLevel ?
'userlogin-reauth' :
'userlogin-loggedin';
572 $submitStatus->warning( $reauthMessage, $this->
getUser()->
getName() );
575 $formHtml = $form->getHTML( $submitStatus );
590 [
'id' =>
'userloginprompt' ], $this->
msg(
'loginprompt' )->parseAsBlock() );
592 $signupStartMsg = $this->
msg(
'signupstart' );
593 $signupStart = ( $this->
isSignup() && !$signupStartMsg->isDisabled() )
594 ?
Html::rawElement(
'div', [
'id' =>
'signupstart' ], $signupStartMsg->parseAsBlock() ) :
'';
595 if ( $languageLinks ) {
601 $benefitsContainer =
'';
609 for ( $benefitIdx = 1; $benefitIdx <= $benefitCount; $benefitIdx++ ) {
610 $headUnescaped = $this->
msg(
"createacct-benefit-head$benefitIdx" )->text();
611 $iconClass = $this->
msg(
"createacct-benefit-icon$benefitIdx" )->text();
612 $benefitList .=
Html::rawElement(
'div', [
'class' =>
"mw-number-text $iconClass" ],
614 $this->
msg(
"createacct-benefit-head$benefitIdx" )->escaped()
617 $this->
msg(
"createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped()
621 $benefitsContainer =
Html::rawElement(
'div', [
'class' =>
'mw-createacct-benefits-container' ],
654 if ( isset( $this->authForm ) ) {
658 $usingHTTPS = $this->
getRequest()->getProtocol() ===
'https';
661 $fieldInfo = AuthenticationRequest::mergeFieldInfo(
$requests );
676 $form->addHiddenField(
'authAction', $this->authAction );
677 if ( $this->mLanguage ) {
678 $form->addHiddenField(
'uselang', $this->mLanguage );
680 $form->addHiddenField(
'force', $this->securityLevel );
685 $form->addHiddenField(
'wpForceHttps', (
int)$this->mStickHTTPS );
686 $form->addHiddenField(
'wpFromhttp', $usingHTTPS );
692 $form->setName(
'userlogin' . ( $this->
isSignup() ?
'2' :
'' ) );
694 $form->setId(
'userlogin2' );
697 $form->suppressDefaultSubmit();
699 $this->authForm = $form;
718 'mUsername' =>
$request->getText(
'wpName' ),
719 'mPassword' =>
$request->getText(
'wpPassword' ),
720 'mRetype' =>
$request->getText(
'wpRetype' ),
721 'mEmail' =>
$request->getText(
'wpEmail' ),
722 'mRealName' =>
$request->getText(
'wpRealName' ),
723 'mDomain' =>
$request->getText(
'wpDomain' ),
724 'mReason' =>
$request->getText(
'wpReason' ),
725 'mRemember' =>
$request->getCheck(
'wpRemember' ),
738 if ( $data->mUsername ==
'' && $this->isSignup() ) {
739 if (
$user->isLoggedIn() ) {
740 $data->mUsername =
$user->getName();
742 $data->mUsername = $this->
getRequest()->getSession()->suggestLoginUsername();
750 $q =
'action=submitlogin&type=signup';
751 $linkq =
'type=login';
753 $q =
'action=submitlogin&type=login';
754 $linkq =
'type=signup';
757 if ( $this->mReturnTo !==
'' ) {
758 $returnto =
'&returnto=' .
wfUrlencode( $this->mReturnTo );
759 if ( $this->mReturnToQuery !==
'' ) {
760 $returnto .=
'&returntoquery=' .
767 # Don't show a "create account" link if the user can't.
769 # Pass any language selection on to the mode switch link
770 if ( $this->mLanguage ) {
771 $linkq .=
'&uselang=' . urlencode( $this->mLanguage );
774 $template->set(
'createOrLoginHref', $titleObj->getLocalURL( $linkq ) );
788 $template->set(
'name', $data->mUsername );
789 $template->set(
'password', $data->mPassword );
790 $template->set(
'retype', $data->mRetype );
791 $template->set(
'createemailset',
false );
792 $template->set(
'email', $data->mEmail );
793 $template->set(
'realname', $data->mRealName );
794 $template->set(
'domain', $data->mDomain );
795 $template->set(
'reason', $data->mReason );
796 $template->set(
'remember', $data->mRemember );
798 $template->set(
'action', $titleObj->getLocalURL( $q ) );
800 $template->set(
'messagetype', $msgType );
807 $template->set(
'resetlink', $resetLink );
809 ->getRememberUserDuration() !== null );
812 $template->set(
'stickhttps', (
int)$this->mStickHTTPS );
817 $action = $this->
isSignup() ?
'signup' :
'login';
818 $wgAuth->modifyUITemplate(
$template, $action );
826 wfDeprecated(
"reference in UserCreateForm hook",
'1.27' );
831 wfDeprecated(
"reference in UserLoginForm hook",
'1.27' );
842 $specialFields = array_merge( [
'extraInput' ],
843 array_keys( $this->fakeTemplate->getExtraInputDefinitions() ) );
846 foreach ( $coreFieldDescriptors
as $fieldName => $coreField ) {
853 !isset( $fieldInfo[$fieldName] )
855 !isset( $coreField[
'baseField'] )
856 || !isset( $fieldInfo[$coreField[
'baseField']] )
858 && !in_array( $fieldName, $specialFields,
true )
860 !isset( $coreField[
'type'] )
861 || !in_array( $coreField[
'type'], [
'submit',
'info' ],
true )
864 $coreFieldDescriptors[$fieldName] =
null;
870 isset( $coreField[
'label'] )
871 || isset( $coreField[
'label-message'] )
872 || isset( $coreField[
'label-raw'] )
874 unset( $requestField[
'label'], $requestField[
'label-message'], $coreField[
'label-raw'] );
877 $coreFieldDescriptors[$fieldName] += $requestField;
903 $isLoggedIn = $this->
getUser()->isLoggedIn();
904 $continuePart = $this->
isContinued() ?
'continue-' :
'';
905 $anotherPart = $isLoggedIn ?
'another-' :
'';
906 $expiration = $this->
getRequest()->getSession()->getProvider()->getRememberUserDuration();
907 $expirationDays = ceil( $expiration / ( 3600 * 24 ) );
908 $secureLoginLink =
'';
909 if ( $this->mSecureLoginUrl ) {
911 'href' => $this->mSecureLoginUrl,
912 'class' =>
'mw-ui-flush-right mw-secure',
913 ], $this->
msg(
'userlogin-signwithsecure' )->
text() );
915 $usernameHelpLink =
'';
916 if ( !$this->
msg(
'createacct-helpusername' )->isDisabled() ) {
918 'class' =>
'mw-ui-flush-right',
919 ], $this->
msg(
'createacct-helpusername' )->parse() );
923 $fieldDefinitions = [
929 'default' =>
Html::element(
'div', [
'id' =>
'mw-createacct-status-area' ] ),
933 'label-raw' => $this->
msg(
'userlogin-yourname' )->escaped() . $usernameHelpLink,
935 'placeholder-message' => $isLoggedIn ?
'createacct-another-username-ph'
936 :
'userlogin-yourname-ph',
941 'label-message' =>
'createaccountmail',
942 'name' =>
'wpCreateaccountMail',
943 'id' =>
'wpCreateaccountMail',
946 'id' =>
'wpPassword2',
947 'placeholder-message' =>
'createacct-yourpassword-ph',
948 'hide-if' => [
'===',
'wpCreateaccountMail',
'1' ],
952 'baseField' =>
'password',
953 'type' =>
'password',
954 'label-message' =>
'createacct-yourpasswordagain',
956 'cssclass' =>
'loginPassword',
958 'validation-callback' =>
function (
$value, $alldata ) {
959 if ( empty( $alldata[
'mailpassword'] ) && !empty( $alldata[
'password'] ) ) {
961 return $this->
msg(
'htmlform-required' );
962 } elseif (
$value !== $alldata[
'password'] ) {
963 return $this->
msg(
'badretype' );
968 'hide-if' => [
'===',
'wpCreateaccountMail',
'1' ],
969 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
973 'label-message' => $wgEmailConfirmToEdit ?
'createacct-emailrequired'
974 :
'createacct-emailoptional',
976 'cssclass' =>
'loginText',
980 'validation-callback' =>
function (
$value, $alldata ) {
988 return $this->
msg(
'noemailtitle' );
989 } elseif ( !
$value && !empty( $alldata[
'mailpassword'] ) ) {
991 return $this->
msg(
'noemailcreate' );
992 } elseif (
$value && !Sanitizer::validateEmail(
$value ) ) {
993 return $this->
msg(
'invalidemailaddress' );
997 'placeholder-message' =>
'createacct-' . $anotherPart .
'email-ph',
1001 'help-message' => $isLoggedIn ?
'createacct-another-realname-tip'
1002 :
'prefs-help-realname',
1003 'label-message' =>
'createacct-realname',
1004 'cssclass' =>
'loginText',
1006 'id' =>
'wpRealName',
1011 'label-message' =>
'createacct-reason',
1012 'cssclass' =>
'loginText',
1015 'placeholder-message' =>
'createacct-reason-ph',
1018 'createaccount' => [
1021 'default' => $this->
msg(
'createacct-' . $anotherPart . $continuePart .
1023 'name' =>
'wpCreateaccount',
1024 'id' =>
'wpCreateaccount',
1029 $fieldDefinitions = [
1031 'label-raw' => $this->
msg(
'userlogin-yourname' )->escaped() . $secureLoginLink,
1033 'placeholder-message' =>
'userlogin-yourname-ph',
1036 'id' =>
'wpPassword1',
1037 'placeholder-message' =>
'userlogin-yourpassword-ph',
1044 'name' =>
'wpRemember',
1045 'label-message' => $this->
msg(
'userlogin-remembermypassword' )
1046 ->numParams( $expirationDays ),
1047 'id' =>
'wpRemember',
1052 'default' => $this->
msg(
'pt-login-' . $continuePart .
'button' )->text(),
1053 'id' =>
'wpLoginAttempt',
1056 'linkcontainer' => [
1059 'cssclass' =>
'mw-form-related-link-container mw-userlogin-help',
1064 ->inContentLanguage()
1066 ], $this->
msg(
'userlogin-helplink2' )->
text() ),
1077 $fieldDefinitions[
'username'] += [
1080 'cssclass' =>
'loginText',
1084 $fieldDefinitions[
'password'] += [
1085 'type' =>
'password',
1087 'name' =>
'wpPassword',
1088 'cssclass' =>
'loginPassword',
1099 $fieldDefinitions[
'header'] = [
1106 if ( $this->mEntryError ) {
1107 $fieldDefinitions[
'entryError'] = [
1109 'default' =>
Html::rawElement(
'div', [
'class' => $this->mEntryErrorType .
'box', ],
1110 $this->mEntryError ),
1117 unset( $fieldDefinitions[
'linkcontainer'], $fieldDefinitions[
'signupend'] );
1122 $signupendMsg = $this->
msg(
'signupend' );
1123 $signupendHttpsMsg = $this->
msg(
'signupend-https' );
1124 if ( !$signupendMsg->isDisabled() ) {
1125 $usingHTTPS = $this->
getRequest()->getProtocol() ===
'https';
1126 $signupendText = ( $usingHTTPS && !$signupendHttpsMsg->isBlank() )
1127 ? $signupendHttpsMsg->parse() : $signupendMsg->parse();
1128 $fieldDefinitions[
'signupend'] = [
1131 'default' =>
Html::rawElement(
'div', [
'id' =>
'signupend' ], $signupendText ),
1138 if ( $passwordReset->isAllowed( $this->getUser() )->isGood() ) {
1139 $fieldDefinitions[
'passwordReset'] = [
1142 'cssclass' =>
'mw-form-related-link-container',
1145 $this->
msg(
'userlogin-resetpassword-link' )->
text()
1157 if ( $this->mLanguage ) {
1158 $linkq .=
'&uselang=' . urlencode( $this->mLanguage );
1160 $loggedIn = $this->
getUser()->isLoggedIn();
1162 $fieldDefinitions[
'createOrLogin'] = [
1165 'linkQuery' => $linkq,
1166 'default' =>
function (
$params )
use ( $loggedIn, $linkTitle ) {
1168 [
'id' =>
'mw-createaccount' . ( !$loggedIn ?
'-cta' :
'' ),
1169 'class' => ( $loggedIn ?
'mw-form-related-link-container' :
'mw-ui-vform-field' ) ],
1170 ( $loggedIn ?
'' : $this->
msg(
'userlogin-noaccount' )->escaped() )
1173 'id' =>
'mw-createaccount-join' . ( $loggedIn ?
'-loggedin' :
'' ),
1174 'href' => $linkTitle->getLocalURL(
$params[
'linkQuery'] ),
1175 'class' => ( $loggedIn ?
'' :
'mw-ui-button' ),
1179 $loggedIn ?
'userlogin-createanother' :
'userlogin-joinproject'
1190 $fieldDefinitions = array_filter( $fieldDefinitions );
1192 return $fieldDefinitions;
1202 if (
$template->get(
'usedomain',
false ) ) {
1204 $fieldDefinitions[
'domain'] = [
1206 'label-message' =>
'yourdomainname',
1207 'options' => array_combine(
$template->get(
'domainnames', [] ),
1209 'default' =>
$template->get(
'domain',
'' ),
1210 'name' =>
'wpDomain',
1216 $extraInputPos = array_search(
'extrainput', array_keys( $fieldDefinitions ),
true );
1217 $fieldDefinitions = array_slice( $fieldDefinitions, 0, $extraInputPos,
true )
1219 + array_slice( $fieldDefinitions, $extraInputPos + 1,
null,
true );
1221 return $fieldDefinitions;
1249 if ( $this->mReturnTo !==
'' ) {
1250 $returnto =
'returnto=' .
wfUrlencode( $this->mReturnTo );
1251 if ( $this->mReturnToQuery !==
'' ) {
1252 $returnto .=
'&returntoquery=' .
wfUrlencode( $this->mReturnToQuery );
1266 } elseif ( $this->
getUser()->isAllowed(
'createaccount' ) ) {
1274 return $this->
isSignup() ?
'wpCreateaccountToken' :
'wpLoginToken';
1284 $msg = $this->
msg(
'loginlanguagelinks' )->inContentLanguage();
1285 if ( $msg->isBlank() ) {
1288 $langs = explode(
"\n", $msg->text() );
1292 $parts = explode(
'|',
$lang );
1293 if (
count( $parts ) >= 2 ) {
1298 return count( $links ) > 0 ? $this->
msg(
'loginlanguagelabel' )->rawParams(
1299 $this->
getLanguage()->pipeList( $links ) )->escaped() :
'';
1313 return htmlspecialchars( $text );
1316 if ( $this->mReturnTo !==
'' ) {
1323 $attr[
'lang'] = $attr[
'hreflang'] = $targetLanguage->getHtmlCode();
1349 if (
$user->isLoggedIn() ) {
1353 $this->
getRequest()->getSession()->suggestLoginUsername();
1369 && !$this->
getRequest()->getCheck(
'wpName' )
1389 throw new LogicException(
'not used' );
1403 $this->
data[
'extrainput'][] = [
1408 'helptext' => $helptext,
1419 foreach ( $this->
get(
'extrainput', [] )
as $field ) {
1421 'type' => $field[
'type'] ===
'checkbox' ?
'check' : $field[
'type'],
1422 'name' => $field[
'name'],
1423 'value' => $field[
'value'],
1424 'id' => $field[
'name'],
1426 if ( $field[
'msg'] ) {
1427 $definition[
'label-message'] = $this->
getMsg( $field[
'msg'] );
1429 if ( $field[
'helptext'] ) {
1430 $definition[
'help'] = $this->
msgWiki( $field[
'helptext'] );
1435 $name = preg_replace(
'/^wp(?=[A-Z])/',
'', $field[
'name'] );
1436 $definitions[
$name] = $definition;
1439 if ( $this->
haveData(
'extrafields' ) ) {
1440 $definitions[
'extrafields'] = [
1443 'default' => $this->
get(
'extrafields' ),
1447 return $definitions;
1474 self::SUCCESS =>
'success',
1475 self::NO_NAME =>
'no_name',
1476 self::ILLEGAL =>
'illegal',
1477 self::WRONG_PLUGIN_PASS =>
'wrong_plugin_pass',
1478 self::NOT_EXISTS =>
'not_exists',
1479 self::WRONG_PASS =>
'wrong_pass',
1480 self::EMPTY_PASS =>
'empty_pass',
1481 self::RESET_PASS =>
'reset_pass',
1482 self::ABORTED =>
'aborted',
1483 self::CREATE_BLOCKED =>
'create_blocked',
1484 self::THROTTLED =>
'throttled',
1485 self::USER_BLOCKED =>
'user_blocked',
1486 self::NEED_TOKEN =>
'need_token',
1487 self::WRONG_TOKEN =>
'wrong_token',
1488 self::USER_MIGRATED =>
'user_migrated',
1496 parent::__construct();
1528 return is_array(
$res ) ?
true : 0;
1550 return $wgRequest->getSession()->getToken(
'',
'login' )->toString();
1566 $wgRequest->getSession()->resetToken(
'login' );
1576 return $wgRequest->getSession()->getToken(
'',
'createaccount' )->toString();
1592 $wgRequest->getSession()->resetToken(
'createaccount' );
$wgHiddenPrefs
An array of preferences to not show for the user.
Status::newGood()` to allow deletion, and then `return false` from the hook function. Ensure you consume the 'ChangeTagAfterDelete' hook to carry out custom deletion actions. $tag:name of the tag $user:user initiating the action & $status:Status object. See above. 'ChangeTagsListActive':Allows you to nominate which of the tags your extension uses are in active use. & $tags:list of all active tags. Append to this array. 'ChangeTagsAfterUpdateTags':Called after tags have been updated with the ChangeTags::updateTags function. Params:$addedTags:tags effectively added in the update $removedTags:tags effectively removed in the update $prevTags:tags that were present prior to the update $rc_id:recentchanges table id $rev_id:revision table id $log_id:logging table id $params:tag params $rc:RecentChange being tagged when the tagging accompanies the action, or null $user:User who performed the tagging when the tagging is subsequent to the action, or null 'ChangeTagsAllowedAdd':Called when checking if a user can add tags to a change. & $allowedTags:List of all the tags the user is allowed to add. Any tags the user wants to add( $addTags) that are not in this array will cause it to fail. You may add or remove tags to this array as required. $addTags:List of tags user intends to add. $user:User who is adding the tags. 'ChangeUserGroups':Called before user groups are changed. $performer:The User who will perform the change $user:The User whose groups will be changed & $add:The groups that will be added & $remove:The groups that will be removed 'Collation::factory':Called if $wgCategoryCollation is an unknown collation. $collationName:Name of the collation in question & $collationObject:Null. Replace with a subclass of the Collation class that implements the collation given in $collationName. 'ConfirmEmailComplete':Called after a user 's email has been confirmed successfully. $user:user(object) whose email is being confirmed 'ContentAlterParserOutput':Modify parser output for a given content object. Called by Content::getParserOutput after parsing has finished. Can be used for changes that depend on the result of the parsing but have to be done before LinksUpdate is called(such as adding tracking categories based on the rendered HTML). $content:The Content to render $title:Title of the page, as context $parserOutput:ParserOutput to manipulate 'ContentGetParserOutput':Customize parser output for a given content object, called by AbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content. $content:The Content to render $title:Title of the page, as context $revId:The revision ID, as context $options:ParserOptions for rendering. To avoid confusing the parser cache, the output can only depend on parameters provided to this hook function, not on global state. $generateHtml:boolean, indicating whether full HTML should be generated. If false, generation of HTML may be skipped, but other information should still be present in the ParserOutput object. & $output:ParserOutput, to manipulate or replace 'ContentHandlerDefaultModelFor':Called when the default content model is determined for a given title. May be used to assign a different model for that title. $title:the Title in question & $model:the model name. Use with CONTENT_MODEL_XXX constants. 'ContentHandlerForModelID':Called when a ContentHandler is requested for a given content model name, but no entry for that model exists in $wgContentHandlers. Note:if your extension implements additional models via this hook, please use GetContentModels hook to make them known to core. $modeName:the requested content model name & $handler:set this to a ContentHandler object, if desired. 'ContentModelCanBeUsedOn':Called to determine whether that content model can be used on a given page. This is especially useful to prevent some content models to be used in some special location. $contentModel:ID of the content model in question $title:the Title in question. & $ok:Output parameter, whether it is OK to use $contentModel on $title. Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok. 'ContribsPager::getQueryInfo':Before the contributions query is about to run & $pager:Pager object for contributions & $queryInfo:The query for the contribs Pager 'ContribsPager::reallyDoQuery':Called before really executing the query for My Contributions & $data:an array of results of all contribs queries $pager:The ContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'ContributionsLineEnding':Called before a contributions HTML line is finished $page:SpecialPage object for contributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'ContributionsToolLinks':Change tool links above Special:Contributions $id:User identifier $title:User page title & $tools:Array of tool links $specialPage:SpecialPage instance for context and services. Can be either SpecialContributions or DeletedContributionsPage. Extensions should type hint against a generic SpecialPage though. 'ConvertContent':Called by AbstractContent::convert when a conversion to another content model is requested. Handler functions that modify $result should generally return false to disable further attempts at conversion. $content:The Content object to be converted. $toModel:The ID of the content model to convert to. $lossy:boolean indicating whether lossy conversion is allowed. & $result:Output parameter, in case the handler function wants to provide a converted Content object. Note that $result->getContentModel() must return $toModel. 'ContentSecurityPolicyDefaultSource':Modify the allowed CSP load sources. This affects all directives except for the script directive. If you want to add a script source, see ContentSecurityPolicyScriptSource hook. & $defaultSrc:Array of Content-Security-Policy allowed sources $policyConfig:Current configuration for the Content-Security-Policy header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyDirectives':Modify the content security policy directives. Use this only if ContentSecurityPolicyDefaultSource and ContentSecurityPolicyScriptSource do not meet your needs. & $directives:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'ContentSecurityPolicyScriptSource':Modify the allowed CSP script sources. Note that you also have to use ContentSecurityPolicyDefaultSource if you want non-script sources to be loaded from whatever you add. & $scriptSrc:Array of CSP directives $policyConfig:Current configuration for the CSP header $mode:ContentSecurityPolicy::REPORT_ONLY_MODE or ContentSecurityPolicy::FULL_MODE depending on type of header 'CustomEditor':When invoking the page editor Return true to allow the normal editor to be used, or false if implementing a custom editor, e.g. for a special namespace, etc. $article:Article being edited $user:User performing the edit 'DatabaseOraclePostInit':Called after initialising an Oracle database $db:the DatabaseOracle object 'DeletedContribsPager::reallyDoQuery':Called before really executing the query for Special:DeletedContributions Similar to ContribsPager::reallyDoQuery & $data:an array of results of all contribs queries $pager:The DeletedContribsPager object hooked into $offset:Index offset, inclusive $limit:Exact query limit $descending:Query direction, false for ascending, true for descending 'DeletedContributionsLineEnding':Called before a DeletedContributions HTML line is finished. Similar to ContributionsLineEnding $page:SpecialPage object for DeletedContributions & $ret:the HTML line $row:the DB row for this line & $classes:the classes to add to the surrounding< li > & $attribs:associative array of other HTML attributes for the< li > element. Currently only data attributes reserved to MediaWiki are allowed(see Sanitizer::isReservedDataAttribute). 'DeleteUnknownPreferences':Called by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about. This hook is used by extensions that have dynamically-named preferences that should not be deleted in the usual cleanup process. For example, the Gadgets extension creates preferences prefixed with 'gadget-', and so anything with that prefix is excluded from the deletion. &where:An array that will be passed as the $cond parameter to IDatabase::select() to determine what will be deleted from the user_properties table. $db:The IDatabase object, useful for accessing $db->buildLike() etc. 'DifferenceEngineAfterLoadNewText':called in DifferenceEngine::loadNewText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before returning true from this function. $differenceEngine:DifferenceEngine object 'DifferenceEngineLoadTextAfterNewContentIsLoaded':called in DifferenceEngine::loadText() after the new revision 's content has been loaded into the class member variable $differenceEngine->mNewContent but before checking if the variable 's value is null. This hook can be used to inject content into said class member variable. $differenceEngine:DifferenceEngine object 'DifferenceEngineMarkPatrolledLink':Allows extensions to change the "mark as patrolled" link which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a span element which has class="patrollink". $differenceEngine:DifferenceEngine object & $markAsPatrolledLink:The "mark as patrolled" link HTML(string) $rcid:Recent change ID(rc_id) for this change(int) 'DifferenceEngineMarkPatrolledRCID':Allows extensions to possibly change the rcid parameter. For example the rcid might be set to zero due to the user being the same as the performer of the change but an extension might still want to show it under certain conditions. & $rcid:rc_id(int) of the change or 0 $differenceEngine:DifferenceEngine object $change:RecentChange object $user:User object representing the current user 'DifferenceEngineNewHeader':Allows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision 's author, whether the revision was marked as a minor edit or not, etc. $differenceEngine:DifferenceEngine object & $newHeader:The string containing the various #mw-diff-otitle[1-5] divs, which include things like revision author info, revision comment, RevisionDelete link and more $formattedRevisionTools:Array containing revision tools, some of which may have been injected with the DiffRevisionTools hook $nextlink:String containing the link to the next revision(if any) $status
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.
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
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
postProcessFormDescriptor(&$formDescriptor, $requests)
msg( $key)
Wrapper around wfMessage that sets the current context.
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.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
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.
$wgPasswordResetRoutes
Whether to allow password resets ("enter some identifying data, and we'll send an email with a tempor...
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.
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
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,...
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 use $formDescriptor instead & $formDescriptor
getSkin()
Shortcut to get the skin being used for this instance.
getLanguage()
Shortcut to get user's language.
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
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
$wgLoginLanguageSelector
Show a bar of language selection links in the user login and user registration forms; edit the "login...
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.
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
mainLoginForm(array $requests, $msg='', $msgtype='error')
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.
see documentation in includes Linker php for Linker::makeImageLink & $time
makeLanguageSelector()
Produce a bar of links which allow the user to select another language during login/registration but ...
hasSessionCookie()
Check if a session cookie is present.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
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.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Allows to change the fields on the form that will be generated $name
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.
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()
Get the RequestContext object associated with the main request.
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.
$wgEmailConfirmToEdit
Should editors be required to have a validated e-mail address before being allowed to edit?
execute()
Main function, used by classes that subclass QuickTemplate to show the actual HTML output.
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
$wgDisableCookieCheck
By default, MediaWiki checks if the client supports cookies during the login process,...
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.
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.
User $targetUser
FIXME another flag for passing data.
$wgAuth $wgAuth
Authentication plugin.
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 $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
if(! $wgDBerrorLogTZ) $wgRequest
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
successfulAction( $direct=false, $extraMessages=null)
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 MediaWikiServices
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.
$wgSecureLogin
This is to let user authenticate using https when they come from http.
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...
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.
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