67 abstract protected function isSignup();
75 abstract protected function successfulAction( $direct =
false, $extraMessages = null );
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' )->escaped(),
157 'returnto' => $this->mReturnTo,
158 'returntoquery' => $this->mReturnToQuery,
159 'uselang' => $this->mLanguage,
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 ( bug 33997 )
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() && !$session->canSetUser() ) {
228 throw new ErrorPageError(
'cannotloginnow-title',
'cannotloginnow-text', [
247 if ( !$this->
isSignup() && !$this->mPosted && !$this->securityLevel &&
248 ( $this->mReturnTo !==
'' || $this->mReturnToQuery !==
'' ) &&
256 if ( $this->
getRequest()->getProtocol() !==
'https' ) {
260 ( $this->mEntryErrorType ===
'error' ?
'error'
261 :
'warning' ) => $this->mEntryError,
264 if ( $wgSecureLogin && !$this->mFromHTTP &&
271 $this->
getOutput()->addVaryHeader(
'X-Forwarded-Proto' );
278 if ( substr( $url, 0, 8 ) ===
'https://' ) {
279 $this->mSecureLoginUrl = $url;
288 $this->
mainLoginForm( [],
'authpage-cannot-' . $this->authAction );
305 case AuthenticationResponse::PASS:
307 $this->proxyAccountCreation = $this->
isSignup() && !$this->
getUser()->isAnon();
311 !$this->proxyAccountCreation
313 && $authManager->canAuthenticateNow()
316 $response2 = $authManager->beginAuthentication( [
$response->loginRequest ],
318 if ( $response2->status !== AuthenticationResponse::PASS ) {
319 LoggerFactory::getInstance(
'login' )
320 ->error(
'Could not log in after account creation' );
326 if ( !$this->proxyAccountCreation ) {
333 case AuthenticationResponse::FAIL:
335 case AuthenticationResponse::RESTART:
336 unset( $this->authForm );
337 if (
$response->status === AuthenticationResponse::FAIL ) {
339 $messageType =
'error';
342 $messageType =
'warning';
348 case AuthenticationResponse::REDIRECT:
349 unset( $this->authForm );
352 case AuthenticationResponse::UI:
353 unset( $this->authForm );
354 $this->authAction = $this->
isSignup() ? AuthManager::ACTION_CREATE_CONTINUE
355 : AuthManager::ACTION_LOGIN_CONTINUE;
356 $this->authRequests =
$response->neededRequests;
360 throw new LogicException(
'invalid AuthenticationResponse' );
374 $type,
$title, $msgname, $injected_html, $extraMessages
381 if ( $extraMessages ) {
383 $out->addWikiText( $extraMessages->getWikiText() );
386 $out->addHTML( $injected_html );
389 $helper->showReturnToPage(
$type, $this->mReturnTo, $this->mReturnToQuery, $this->mStickHTTPS );
463 $this->authForm = null;
464 $requests = AuthManager::singleton()->getAuthenticationRequests( $this->authAction,
$user );
468 $out->addModuleStyles( [
470 'mediawiki.ui.button',
471 'mediawiki.ui.checkbox',
472 'mediawiki.ui.input',
473 'mediawiki.special.userlogin.common.styles'
477 $out->addJsConfigVars(
'wgCreateacctImgcaptchaHelp',
478 $this->
msg(
'createacct-imgcaptcha-help' )->parse() );
482 'mediawiki.special.userlogin.signup.js'
484 $out->addModuleStyles( [
485 'mediawiki.special.userlogin.signup.styles'
489 $out->addModuleStyles( [
490 'mediawiki.special.userlogin.login.styles'
493 $out->disallowUserJs();
495 $form = $this->
getAuthForm( $requests, $this->authAction, $msg, $msgtype );
496 $form->prepareForm();
512 [
'id' =>
'userloginprompt' ], $this->
msg(
'loginprompt' )->parseAsBlock() );
514 $signupStartMsg = $this->
msg(
'signupstart' );
515 $signupStart = ( $this->
isSignup() && !$signupStartMsg->isDisabled() )
516 ?
Html::rawElement(
'div', [
'id' =>
'signupstart' ], $signupStartMsg->parseAsBlock() ) :
'';
517 if ( $languageLinks ) {
523 $benefitsContainer =
'';
531 for ( $benefitIdx = 1; $benefitIdx <= $benefitCount; $benefitIdx++ ) {
532 $headUnescaped = $this->
msg(
"createacct-benefit-head$benefitIdx" )->text();
533 $iconClass = $this->
msg(
"createacct-benefit-icon$benefitIdx" )->escaped();
534 $benefitList .=
Html::rawElement(
'div', [
'class' =>
"mw-number-text $iconClass" ],
536 $this->
msg(
"createacct-benefit-head$benefitIdx" )->escaped()
539 $this->
msg(
"createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped()
543 $benefitsContainer =
Html::rawElement(
'div', [
'class' =>
'mw-createacct-benefits-container' ],
576 if ( isset( $this->authForm ) ) {
580 $usingHTTPS = $this->
getRequest()->getProtocol() ===
'https';
583 $fieldInfo = AuthenticationRequest::mergeFieldInfo( $requests );
587 $formDescriptor = static::fieldInfoToFormDescriptor( $requests, $fieldInfo, $this->authAction );
598 $form->addHiddenField(
'authAction', $this->authAction );
599 if ( $wgLoginLanguageSelector ) {
600 $form->addHiddenField(
'uselang', $this->mLanguage );
602 $form->addHiddenField(
'force', $this->securityLevel );
604 if ( $wgSecureLogin ) {
607 $form->addHiddenField(
'wpForceHttps', (
int)$this->mStickHTTPS );
608 $form->addHiddenField(
'wpFromhttp', $usingHTTPS );
614 $form->setName(
'userlogin' . ( $this->
isSignup() ?
'2' :
'' ) );
616 $form->setId(
'userlogin2' );
629 $statusAreaAttribs = [
'id' =>
'mw-createacct-status-area' ];
631 $form->addHeaderText(
Html::element(
'div', $statusAreaAttribs ) );
640 $signupendMsg = $this->
msg(
'signupend' );
641 $signupendHttpsMsg = $this->
msg(
'signupend-https' );
642 if ( !$signupendMsg->isDisabled() ) {
643 $signupendText = ( $usingHTTPS && !$signupendHttpsMsg->isBlank() )
644 ? $signupendHttpsMsg ->parse() : $signupendMsg->parse();
645 $form->addPostText(
Html::rawElement(
'div', [
'id' =>
'signupend' ], $signupendText ) );
651 $reauthMessage = $this->securityLevel ?
'userlogin-reauth' :
'userlogin-loggedin';
653 $this->
msg( $reauthMessage )->params( $this->
getUser()->
getName() )->parse() ) );
658 if ( $passwordReset->isAllowed( $this->getUser() ) ) {
661 [
'class' =>
'mw-ui-vform-field mw-form-related-link-container' ],
664 $this->
msg(
'userlogin-resetpassword-link' )->escaped()
675 if ( $wgLoginLanguageSelector && $this->mLanguage ) {
679 $loggedIn = $this->
getUser()->isLoggedIn();
681 [
'id' =>
'mw-createaccount' . ( !$loggedIn ?
'-cta' :
'' ),
682 'class' => ( $loggedIn ?
'mw-form-related-link-container' :
'mw-ui-vform-field' ) ],
683 ( $loggedIn ?
'' : $this->
msg(
'userlogin-noaccount' )->escaped() )
686 'id' =>
'mw-createaccount-join' . ( $loggedIn ?
'-loggedin' :
'' ),
687 'href' => $linkTitle->getLocalURL( $linkq ),
688 'class' => ( $loggedIn ?
'' :
'mw-ui-button' ),
692 ( $this->
getUser()->isLoggedIn() ?
693 'userlogin-createanother' :
694 'userlogin-joinproject'
698 $form->addFooterText( $createOrLoginHtml );
702 $form->suppressDefaultSubmit();
704 $this->authForm = $form;
723 'mUsername' =>
$request->getText(
'wpName' ),
724 'mPassword' =>
$request->getText(
'wpPassword' ),
725 'mRetype' =>
$request->getText(
'wpRetype' ),
726 'mEmail' =>
$request->getText(
'wpEmail' ),
727 'mRealName' =>
$request->getText(
'wpRealName' ),
728 'mDomain' =>
$request->getText(
'wpDomain' ),
729 'mReason' =>
$request->getText(
'wpReason' ),
730 'mRemember' =>
$request->getCheck(
'wpRemember' ),
743 if ( $data->mUsername ==
'' && $this->isSignup() ) {
744 if (
$user->isLoggedIn() ) {
745 $data->mUsername =
$user->getName();
747 $data->mUsername = $this->
getRequest()->getSession()->suggestLoginUsername();
755 $q =
'action=submitlogin&type=signup';
756 $linkq =
'type=login';
758 $q =
'action=submitlogin&type=login';
759 $linkq =
'type=signup';
762 if ( $this->mReturnTo !==
'' ) {
763 $returnto =
'&returnto=' .
wfUrlencode( $this->mReturnTo );
764 if ( $this->mReturnToQuery !==
'' ) {
765 $returnto .=
'&returntoquery=' .
772 # Don't show a "create account" link if the user can't.
774 # Pass any language selection on to the mode switch link
775 if ( $wgLoginLanguageSelector && $this->mLanguage ) {
779 $template->set(
'createOrLoginHref', $titleObj->getLocalURL( $linkq ) );
786 : is_array( $wgPasswordResetRoutes )
787 && in_array(
true, array_values( $wgPasswordResetRoutes ),
true );
793 $template->set(
'name', $data->mUsername );
794 $template->set(
'password', $data->mPassword );
795 $template->set(
'retype', $data->mRetype );
796 $template->set(
'createemailset',
false );
797 $template->set(
'email', $data->mEmail );
798 $template->set(
'realname', $data->mRealName );
799 $template->set(
'domain', $data->mDomain );
800 $template->set(
'reason', $data->mReason );
801 $template->set(
'remember', $data->mRemember );
803 $template->set(
'action', $titleObj->getLocalURL( $q ) );
805 $template->set(
'messagetype', $msgType );
806 $template->set(
'createemail', $wgEnableEmail &&
$user->isLoggedIn() );
807 $template->set(
'userealname', !in_array(
'realname', $wgHiddenPrefs,
true ) );
808 $template->set(
'useemail', $wgEnableEmail );
809 $template->set(
'emailrequired', $wgEmailConfirmToEdit );
810 $template->set(
'emailothers', $wgEnableUserEmail );
811 $template->set(
'canreset', $wgAuth->allowPasswordChange() );
812 $template->set(
'resetlink', $resetLink );
814 ->getRememberUserDuration() !== null );
816 $template->set(
'cansecurelogin', ( $wgSecureLogin ) );
817 $template->set(
'stickhttps', (
int)$this->mStickHTTPS );
822 $action = $this->
isSignup() ?
'signup' :
'login';
823 $wgAuth->modifyUITemplate(
$template, $action );
826 $hookName = $this->
isSignup() ?
'UserCreateForm' :
'UserLoginForm';
840 $specialFields = array_merge( [
'extraInput',
'linkcontainer',
'entryError' ],
841 array_keys( $this->fakeTemplate->getExtraInputDefinitions() ) );
844 foreach ( $coreFieldDescriptors
as $fieldName => $coreField ) {
845 $requestField = isset( $formDescriptor[$fieldName] ) ?
846 $formDescriptor[$fieldName] : [];
851 !isset( $fieldInfo[$fieldName] )
853 !isset( $coreField[
'baseField'] )
854 || !isset( $fieldInfo[$coreField[
'baseField']] )
855 ) && !in_array( $fieldName, $specialFields,
true )
856 && ( !isset( $coreField[
'type'] ) || $coreField[
'type'] !==
'submit' )
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 );
897 $isLoggedIn = $this->
getUser()->isLoggedIn();
898 $continuePart = $this->
isContinued() ?
'continue-' :
'';
899 $anotherPart = $isLoggedIn ?
'another-' :
'';
900 $expiration = $this->
getRequest()->getSession()->getProvider()
901 ->getRememberUserDuration();
902 $expirationDays = ceil( $expiration / ( 3600 * 24 ) );
903 $secureLoginLink =
'';
904 if ( $this->mSecureLoginUrl ) {
906 'href' => $this->mSecureLoginUrl,
907 'class' =>
'mw-ui-flush-right mw-secure',
908 ], $this->
msg(
'userlogin-signwithsecure' )->
text() );
912 $fieldDefinitions = [
914 'label-message' =>
'userlogin-yourname',
916 'help-message' =>
'createacct-helpusername',
918 'placeholder-message' => $isLoggedIn ?
'createacct-another-username-ph'
919 :
'userlogin-yourname-ph',
924 'label-message' =>
'createaccountmail',
925 'name' =>
'wpCreateaccountMail',
926 'id' =>
'wpCreateaccountMail',
929 'id' =>
'wpPassword2',
930 'placeholder-message' =>
'createacct-yourpassword-ph',
931 'hide-if' => [
'===',
'wpCreateaccountMail',
'1' ],
935 'baseField' =>
'password',
936 'type' =>
'password',
937 'label-message' =>
'createacct-yourpasswordagain',
939 'cssclass' =>
'loginPassword',
941 'validation-callback' =>
function (
$value, $alldata ) {
942 if ( empty( $alldata[
'mailpassword'] ) && !empty( $alldata[
'password'] ) ) {
944 return $this->
msg(
'htmlform-required' );
945 } elseif (
$value !== $alldata[
'password'] ) {
946 return $this->
msg(
'badretype' );
951 'hide-if' => [
'===',
'wpCreateaccountMail',
'1' ],
952 'placeholder-message' =>
'createacct-yourpasswordagain-ph',
956 'label-message' => $wgEmailConfirmToEdit ?
'createacct-emailrequired'
957 :
'createacct-emailoptional',
959 'cssclass' =>
'loginText',
963 'validation-callback' =>
function (
$value, $alldata ) {
968 if ( !
$value && $wgEmailConfirmToEdit ) {
971 return $this->
msg(
'noemailtitle' );
972 } elseif ( !
$value && !empty( $alldata[
'mailpassword'] ) ) {
974 return $this->
msg(
'noemailcreate' );
976 return $this->
msg(
'invalidemailaddress' );
980 'placeholder-message' =>
'createacct-' . $anotherPart .
'email-ph',
984 'help-message' => $isLoggedIn ?
'createacct-another-realname-tip'
985 :
'prefs-help-realname',
986 'label-message' =>
'createacct-realname',
987 'cssclass' =>
'loginText',
989 'id' =>
'wpRealName',
994 'label-message' =>
'createacct-reason',
995 'cssclass' =>
'loginText',
998 'placeholder-message' =>
'createacct-reason-ph',
1001 'createaccount' => [
1004 'default' => $this->
msg(
'createacct-' . $anotherPart . $continuePart .
1006 'name' =>
'wpCreateaccount',
1007 'id' =>
'wpCreateaccount',
1012 $fieldDefinitions = [
1014 'label-raw' => $this->
msg(
'userlogin-yourname' )->escaped() . $secureLoginLink,
1016 'placeholder-message' =>
'userlogin-yourname-ph',
1019 'id' =>
'wpPassword1',
1020 'placeholder-message' =>
'userlogin-yourpassword-ph',
1027 'name' =>
'wpRemember',
1028 'label-message' => $this->
msg(
'userlogin-remembermypassword' )
1029 ->numParams( $expirationDays ),
1030 'id' =>
'wpRemember',
1035 'default' => $this->
msg(
'pt-login-' . $continuePart .
'button' )->text(),
1036 'id' =>
'wpLoginAttempt',
1039 'linkcontainer' => [
1042 'cssclass' =>
'mw-form-related-link-container mw-userlogin-help',
1047 ->inContentLanguage()
1049 ], $this->
msg(
'userlogin-helplink2' )->
text() ),
1059 $fieldDefinitions[
'username'] += [
1062 'cssclass' =>
'loginText',
1066 $fieldDefinitions[
'password'] += [
1067 'type' =>
'password',
1069 'name' =>
'wpPassword',
1070 'cssclass' =>
'loginPassword',
1075 if ( $this->mEntryError ) {
1076 $fieldDefinitions[
'entryError'] = [
1078 'default' =>
Html::rawElement(
'div', [
'class' => $this->mEntryErrorType .
'box', ],
1079 $this->mEntryError ),
1087 unset( $fieldDefinitions[
'linkcontainer'] );
1091 $fieldDefinitions = array_filter( $fieldDefinitions );
1093 return $fieldDefinitions;
1103 if (
$template->get(
'usedomain',
false ) ) {
1105 $fieldDefinitions[
'domain'] = [
1107 'label-message' =>
'yourdomainname',
1108 'options' => array_combine(
$template->get(
'domainnames', [] ),
1110 'default' =>
$template->get(
'domain',
'' ),
1111 'name' =>
'wpDomain',
1117 $extraInputPos = array_search(
'extrainput', array_keys( $fieldDefinitions ),
true );
1118 $fieldDefinitions = array_slice( $fieldDefinitions, 0, $extraInputPos,
true )
1120 + array_slice( $fieldDefinitions, $extraInputPos + 1, null,
true );
1122 return $fieldDefinitions;
1137 return $wgDisableCookieCheck || (
1138 $wgInitialSessionId &&
1149 if ( $this->mReturnTo !==
'' ) {
1150 $returnto =
'returnto=' .
wfUrlencode( $this->mReturnTo );
1151 if ( $this->mReturnToQuery !==
'' ) {
1152 $returnto .=
'&returntoquery=' .
wfUrlencode( $this->mReturnToQuery );
1166 } elseif ( $this->
getUser()->isAllowed(
'createaccount' ) ) {
1174 return $this->
isSignup() ?
'wpCreateaccountToken' :
'wpLoginToken';
1184 $msg = $this->
msg(
'loginlanguagelinks' )->inContentLanguage();
1185 if ( $msg->isBlank() ) {
1188 $langs = explode(
"\n", $msg->text() );
1191 $lang = trim( $lang,
'* ' );
1192 $parts = explode(
'|', $lang );
1193 if ( count( $parts ) >= 2 ) {
1198 return count( $links ) > 0 ? $this->
msg(
'loginlanguagelabel' )->rawParams(
1199 $this->
getLanguage()->pipeList( $links ) )->escaped() :
'';
1213 return htmlspecialchars( $text );
1216 if ( $this->mReturnTo !==
'' ) {
1223 $attr[
'lang'] = $attr[
'hreflang'] = $targetLanguage->getHtmlCode();
1227 htmlspecialchars( $text ),
1243 isset( $formDescriptor[
'username'] ) &&
1244 !isset( $formDescriptor[
'username'][
'default'] ) &&
1248 if (
$user->isLoggedIn() ) {
1249 $formDescriptor[
'username'][
'default'] =
$user->getName();
1251 $formDescriptor[
'username'][
'default'] =
1252 $this->
getRequest()->getSession()->suggestLoginUsername();
1259 unset( $formDescriptor[
'createaccount'], $formDescriptor[
'loginattempt'] );
1266 isset( $formDescriptor[
'username'] )
1267 && empty( $formDescriptor[
'username'][
'default'] )
1268 && !$this->
getRequest()->getCheck(
'wpName' )
1270 $formDescriptor[
'username'][
'autofocus'] =
true;
1271 } elseif ( isset( $formDescriptor[
'password'] ) ) {
1272 $formDescriptor[
'password'][
'autofocus'] =
true;
1288 throw new LogicException(
'not used' );
1297 $this->
data[
'extrainput'][] = [
1302 'helptext' => $helptext,
1313 foreach ( $this->
get(
'extrainput', [] )
as $field ) {
1315 'type' => $field[
'type'] ===
'checkbox' ?
'check' : $field[
'type'],
1316 'name' => $field[
'name'],
1317 'value' => $field[
'value'],
1318 'id' => $field[
'name'],
1320 if ( $field[
'msg'] ) {
1321 $definition[
'label-message'] = $this->
getMsg( $field[
'msg'] );
1323 if ( $field[
'helptext'] ) {
1324 $definition[
'help'] = $this->
msgWiki( $field[
'helptext'] );
1329 $name = preg_replace(
'/^wp(?=[A-Z])/',
'', $field[
'name'] );
1330 $definitions[
$name] = $definition;
1333 if ( $this->
haveData(
'extrafields' ) ) {
1334 $definitions[
'extrafields'] = [
1337 'default' => $this->
get(
'extrafields' ),
1341 return $definitions;
1355 if ( $wgDisableAuthManager ) {
1365 return $this->realLoginForm->$name;
1369 $this->realLoginForm->$name =
$value;
1373 return call_user_func_array( [ $this->realLoginForm,
$name ],
$args );
1385 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1388 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1391 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1394 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1397 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1400 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1403 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1406 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1409 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1412 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1415 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1418 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1421 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1424 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1427 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1430 $reasonMsg =
'exception-nologin-text', $titleMsg =
'exception-nologin'
1432 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1435 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1438 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1441 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1444 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1447 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1450 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1453 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1456 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1459 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1462 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1465 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1468 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1471 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1474 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1477 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1480 return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
1502 self::SUCCESS =>
'success',
1503 self::NO_NAME =>
'no_name',
1504 self::ILLEGAL =>
'illegal',
1505 self::WRONG_PLUGIN_PASS =>
'wrong_plugin_pass',
1506 self::NOT_EXISTS =>
'not_exists',
1508 self::EMPTY_PASS =>
'empty_pass',
1509 self::RESET_PASS =>
'reset_pass',
1510 self::ABORTED =>
'aborted',
1511 self::CREATE_BLOCKED =>
'create_blocked',
1512 self::THROTTLED =>
'throttled',
1513 self::USER_BLOCKED =>
'user_blocked',
1514 self::NEED_TOKEN =>
'need_token',
1515 self::WRONG_TOKEN =>
'wrong_token',
1516 self::USER_MIGRATED =>
'user_migrated',
1520 'exception-nologin-text',
1521 'watchlistanontext',
1522 'changeemail-no-info',
1523 'resetpass-no-info',
1524 'confirmemail_needlogin',
1525 'prefsnologintext2',
1552 self::SUCCESS =>
'success',
1553 self::NO_NAME =>
'no_name',
1554 self::ILLEGAL =>
'illegal',
1555 self::WRONG_PLUGIN_PASS =>
'wrong_plugin_pass',
1556 self::NOT_EXISTS =>
'not_exists',
1558 self::EMPTY_PASS =>
'empty_pass',
1559 self::RESET_PASS =>
'reset_pass',
1560 self::ABORTED =>
'aborted',
1561 self::CREATE_BLOCKED =>
'create_blocked',
1562 self::THROTTLED =>
'throttled',
1563 self::USER_BLOCKED =>
'user_blocked',
1564 self::NEED_TOKEN =>
'need_token',
1565 self::WRONG_TOKEN =>
'wrong_token',
1566 self::USER_MIGRATED =>
'user_migrated',
1574 parent::__construct();
1592 return $throttler->increase(
$username, $wgRequest->getIP(), __METHOD__ );
1601 return is_array(
$res ) ?
true : 0;
1612 return $throttler->clear(
$username, $wgRequest->getIP() );
1621 return $wgRequest->getSession()->getToken(
'',
'login' )->toString();
1637 $wgRequest->getSession()->resetToken(
'login' );
1646 return $wgRequest->getSession()->getToken(
'',
'createaccount' )->toString();
1662 $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 ...
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.
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.
makeLanguageSelector()
Produce a bar of links which allow the user to select another language during login/registration but ...
needsSubmitButton($formDescriptor)
Returns true if the form has fields which take values.
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.
$wgSecureLogin
This is to let user authenticate using https when they come from http.
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...
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
getToken()
Returns the CSRF token.
mainLoginForm(array $requests, $msg= '', $msgtype= 'error')
msg()
Wrapper around wfMessage that sets the current context.
$wgEmailConfirmToEdit
Should editors be required to have a validated e-mail address before being allowed to edit...
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.
$wgAuth $wgAuth
Authentication plugin.
$wgHiddenPrefs
An array of preferences to not show for the user.
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.
$wgPasswordResetRoutes
Whether to allow password resets ("enter some identifying data, and we'll send an email with a tempo...
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
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
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.
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.
$wgDisableCookieCheck
By default, MediaWiki checks if the client supports cookies during the login process, so that it can display an informative error message if cookies are disabled.
getBCFieldDefinitions($fieldDefinitions, $template)
Adds fields provided via the deprecated UserLoginForm / UserCreateForm hooks.
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.
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 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 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"<
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 conditions will AND in the final query as a Content object as a Content object $title
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
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.
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 conditions will AND in the final query as a Content object as a Content object the(raw HTML) error message to display(added in 1.13) &$status hooks can tweak the array to change how login etc forms should look $requests
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.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
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.
$wgDisableAuthManager
Disable AuthManager.
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.
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 and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired 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 inclusive $limit
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.
postProcessFormDescriptor(&$formDescriptor)
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.