MediaWiki  1.34.0
LoginSignupSpecialPage.php
Go to the documentation of this file.
1 <?php
30 use Wikimedia\ScopedCallback;
31 
38  protected $mReturnTo;
39  protected $mPosted;
40  protected $mAction;
41  protected $mLanguage;
42  protected $mReturnToQuery;
43  protected $mToken;
44  protected $mStickHTTPS;
45  protected $mFromHTTP;
46  protected $mEntryError = '';
47  protected $mEntryErrorType = 'error';
48 
49  protected $mLoaded = false;
50  protected $mLoadedRequest = false;
51  protected $mSecureLoginUrl;
52 
54  protected $securityLevel;
55 
61  protected $targetUser;
62 
64  protected $authForm;
65 
66  abstract protected function isSignup();
67 
74  abstract protected function successfulAction( $direct = false, $extraMessages = null );
75 
81  abstract protected function logAuthResult( $success, $status = null );
82 
83  public function __construct( $name ) {
85  parent::__construct( $name );
86 
87  // Override UseMediaWikiEverywhere to true, to force login and create form to use mw ui
89  }
90 
91  protected function setRequest( array $data, $wasPosted = null ) {
92  parent::setRequest( $data, $wasPosted );
93  $this->mLoadedRequest = false;
94  }
95 
99  private function loadRequestParameters() {
100  if ( $this->mLoadedRequest ) {
101  return;
102  }
103  $this->mLoadedRequest = true;
104  $request = $this->getRequest();
105 
106  $this->mPosted = $request->wasPosted();
107  $this->mAction = $request->getVal( 'action' );
108  $this->mFromHTTP = $request->getBool( 'fromhttp', false )
109  || $request->getBool( 'wpFromhttp', false );
110  $this->mStickHTTPS = ( !$this->mFromHTTP && $request->getProtocol() === 'https' )
111  || $request->getBool( 'wpForceHttps', false );
112  $this->mLanguage = $request->getText( 'uselang' );
113  $this->mReturnTo = $request->getVal( 'returnto', '' );
114  $this->mReturnToQuery = $request->getVal( 'returntoquery', '' );
115  }
116 
122  protected function load( $subPage ) {
123  global $wgSecureLogin;
124 
125  $this->loadRequestParameters();
126  if ( $this->mLoaded ) {
127  return;
128  }
129  $this->mLoaded = true;
130  $request = $this->getRequest();
131 
132  $securityLevel = $this->getRequest()->getText( 'force' );
133  if (
134  $securityLevel && AuthManager::singleton()->securitySensitiveOperationStatus(
135  $securityLevel ) === AuthManager::SEC_REAUTH
136  ) {
137  $this->securityLevel = $securityLevel;
138  }
139 
140  $this->loadAuth( $subPage );
141 
142  $this->mToken = $request->getVal( $this->getTokenName() );
143 
144  // Show an error or warning passed on from a previous page
145  $entryError = $this->msg( $request->getVal( 'error', '' ) );
146  $entryWarning = $this->msg( $request->getVal( 'warning', '' ) );
147  // bc: provide login link as a parameter for messages where the translation
148  // was not updated
149  $loginreqlink = $this->getLinkRenderer()->makeKnownLink(
150  $this->getPageTitle(),
151  $this->msg( 'loginreqlink' )->text(),
152  [],
153  [
154  'returnto' => $this->mReturnTo,
155  'returntoquery' => $this->mReturnToQuery,
156  'uselang' => $this->mLanguage ?: null,
157  'fromhttp' => $wgSecureLogin && $this->mFromHTTP ? '1' : null,
158  ]
159  );
160 
161  // Only show valid error or warning messages.
162  if ( $entryError->exists()
163  && in_array( $entryError->getKey(), LoginHelper::getValidErrorMessages(), true )
164  ) {
165  $this->mEntryErrorType = 'error';
166  $this->mEntryError = $entryError->rawParams( $loginreqlink )->parse();
167 
168  } elseif ( $entryWarning->exists()
169  && in_array( $entryWarning->getKey(), LoginHelper::getValidErrorMessages(), true )
170  ) {
171  $this->mEntryErrorType = 'warning';
172  $this->mEntryError = $entryWarning->rawParams( $loginreqlink )->parse();
173  }
174 
175  # 1. When switching accounts, it sucks to get automatically logged out
176  # 2. Do not return to PasswordReset after a successful password change
177  # but goto Wiki start page (Main_Page) instead ( T35997 )
178  $returnToTitle = Title::newFromText( $this->mReturnTo );
179  if ( is_object( $returnToTitle )
180  && ( $returnToTitle->isSpecial( 'Userlogout' )
181  || $returnToTitle->isSpecial( 'PasswordReset' ) )
182  ) {
183  $this->mReturnTo = '';
184  $this->mReturnToQuery = '';
185  }
186  }
187 
188  protected function getPreservedParams( $withToken = false ) {
189  global $wgSecureLogin;
190 
191  $params = parent::getPreservedParams( $withToken );
192  $params += [
193  'returnto' => $this->mReturnTo ?: null,
194  'returntoquery' => $this->mReturnToQuery ?: null,
195  ];
196  if ( $wgSecureLogin && !$this->isSignup() ) {
197  $params['fromhttp'] = $this->mFromHTTP ? '1' : null;
198  }
199  return $params;
200  }
201 
202  protected function beforeExecute( $subPage ) {
203  // finish initializing the class before processing the request - T135924
204  $this->loadRequestParameters();
205  return parent::beforeExecute( $subPage );
206  }
207 
212  public function execute( $subPage ) {
213  if ( $this->mPosted ) {
214  $time = microtime( true );
215  $profilingScope = new ScopedCallback( function () use ( $time ) {
216  $time = microtime( true ) - $time;
217  $statsd = MediaWikiServices::getInstance()->getStatsdDataFactory();
218  $statsd->timing( "timing.login.ui.{$this->authAction}", $time * 1000 );
219  } );
220  }
221 
222  $authManager = AuthManager::singleton();
223  $session = SessionManager::getGlobalSession();
224 
225  // Session data is used for various things in the authentication process, so we must make
226  // sure a session cookie or some equivalent mechanism is set.
227  $session->persist();
228 
229  $this->load( $subPage );
230  $this->setHeaders();
231  $this->checkPermissions();
232 
233  // Make sure the system configuration allows log in / sign up
234  if ( !$this->isSignup() && !$authManager->canAuthenticateNow() ) {
235  if ( !$session->canSetUser() ) {
236  throw new ErrorPageError( 'cannotloginnow-title', 'cannotloginnow-text', [
237  $session->getProvider()->describe( RequestContext::getMain()->getLanguage() )
238  ] );
239  }
240  throw new ErrorPageError( 'cannotlogin-title', 'cannotlogin-text' );
241  } elseif ( $this->isSignup() && !$authManager->canCreateAccounts() ) {
242  throw new ErrorPageError( 'cannotcreateaccount-title', 'cannotcreateaccount-text' );
243  }
244 
245  /*
246  * In the case where the user is already logged in, and was redirected to
247  * the login form from a page that requires login, do not show the login
248  * page. The use case scenario for this is when a user opens a large number
249  * of tabs, is redirected to the login page on all of them, and then logs
250  * in on one, expecting all the others to work properly.
251  *
252  * However, do show the form if it was visited intentionally (no 'returnto'
253  * is present). People who often switch between several accounts have grown
254  * accustomed to this behavior.
255  *
256  * Also make an exception when force=<level> is set in the URL, which means the user must
257  * reauthenticate for security reasons.
258  */
259  if ( !$this->isSignup() && !$this->mPosted && !$this->securityLevel &&
260  ( $this->mReturnTo !== '' || $this->mReturnToQuery !== '' ) &&
261  $this->getUser()->isLoggedIn()
262  ) {
263  $this->successfulAction();
264  return;
265  }
266 
267  // If logging in and not on HTTPS, either redirect to it or offer a link.
268  global $wgSecureLogin;
269  if ( $this->getRequest()->getProtocol() !== 'https' ) {
270  $title = $this->getFullTitle();
271  $query = $this->getPreservedParams( false ) + [
272  'title' => null,
273  ( $this->mEntryErrorType === 'error' ? 'error'
274  : 'warning' ) => $this->mEntryError,
275  ] + $this->getRequest()->getQueryValues();
276  $url = $title->getFullURL( $query, false, PROTO_HTTPS );
277  if ( $wgSecureLogin && !$this->mFromHTTP &&
278  wfCanIPUseHTTPS( $this->getRequest()->getIP() )
279  ) {
280  // Avoid infinite redirect
281  $url = wfAppendQuery( $url, 'fromhttp=1' );
282  $this->getOutput()->redirect( $url );
283  // Since we only do this redir to change proto, always vary
284  $this->getOutput()->addVaryHeader( 'X-Forwarded-Proto' );
285 
286  return;
287  } else {
288  // A wiki without HTTPS login support should set $wgServer to
289  // http://somehost, in which case the secure URL generated
290  // above won't actually start with https://
291  if ( substr( $url, 0, 8 ) === 'https://' ) {
292  $this->mSecureLoginUrl = $url;
293  }
294  }
295  }
296 
297  if ( !$this->isActionAllowed( $this->authAction ) ) {
298  // FIXME how do we explain this to the user? can we handle session loss better?
299  // messages used: authpage-cannot-login, authpage-cannot-login-continue,
300  // authpage-cannot-create, authpage-cannot-create-continue
301  $this->mainLoginForm( [], 'authpage-cannot-' . $this->authAction );
302  return;
303  }
304 
305  if ( $this->canBypassForm( $button_name ) ) {
306  $this->setRequest( [], true );
307  $this->getRequest()->setVal( $this->getTokenName(), $this->getToken() );
308  if ( $button_name ) {
309  $this->getRequest()->setVal( $button_name, true );
310  }
311  }
312 
313  $status = $this->trySubmit();
314 
315  if ( !$status || !$status->isGood() ) {
316  $this->mainLoginForm( $this->authRequests, $status ? $status->getMessage() : '', 'error' );
317  return;
318  }
319 
321  $response = $status->getValue();
322 
323  $returnToUrl = $this->getPageTitle( 'return' )
324  ->getFullURL( $this->getPreservedParams( true ), false, PROTO_HTTPS );
325  switch ( $response->status ) {
326  case AuthenticationResponse::PASS:
327  $this->logAuthResult( true );
328  $this->proxyAccountCreation = $this->isSignup() && !$this->getUser()->isAnon();
329  $this->targetUser = User::newFromName( $response->username );
330 
331  if (
332  !$this->proxyAccountCreation
333  && $response->loginRequest
334  && $authManager->canAuthenticateNow()
335  ) {
336  // successful registration; log the user in instantly
337  $response2 = $authManager->beginAuthentication( [ $response->loginRequest ],
338  $returnToUrl );
339  if ( $response2->status !== AuthenticationResponse::PASS ) {
340  LoggerFactory::getInstance( 'login' )
341  ->error( 'Could not log in after account creation' );
342  $this->successfulAction( true, Status::newFatal( 'createacct-loginerror' ) );
343  break;
344  }
345  }
346 
347  if ( !$this->proxyAccountCreation ) {
348  // Ensure that the context user is the same as the session user.
350  }
351 
352  $this->successfulAction( true );
353  break;
354  case AuthenticationResponse::FAIL:
355  // fall through
356  case AuthenticationResponse::RESTART:
357  unset( $this->authForm );
358  if ( $response->status === AuthenticationResponse::FAIL ) {
359  $action = $this->getDefaultAction( $subPage );
360  $messageType = 'error';
361  } else {
362  $action = $this->getContinueAction( $this->authAction );
363  $messageType = 'warning';
364  }
365  $this->logAuthResult( false, $response->message ? $response->message->getKey() : '-' );
366  $this->loadAuth( $subPage, $action, true );
367  $this->mainLoginForm( $this->authRequests, $response->message, $messageType );
368  break;
369  case AuthenticationResponse::REDIRECT:
370  unset( $this->authForm );
371  $this->getOutput()->redirect( $response->redirectTarget );
372  break;
373  case AuthenticationResponse::UI:
374  unset( $this->authForm );
375  $this->authAction = $this->isSignup() ? AuthManager::ACTION_CREATE_CONTINUE
376  : AuthManager::ACTION_LOGIN_CONTINUE;
377  $this->authRequests = $response->neededRequests;
378  $this->mainLoginForm( $response->neededRequests, $response->message, $response->messageType );
379  break;
380  default:
381  throw new LogicException( 'invalid AuthenticationResponse' );
382  }
383  }
384 
398  private function canBypassForm( &$button_name ) {
399  $button_name = null;
400  if ( $this->isContinued() ) {
401  return false;
402  }
403  $fields = AuthenticationRequest::mergeFieldInfo( $this->authRequests );
404  foreach ( $fields as $fieldname => $field ) {
405  if ( !isset( $field['type'] ) ) {
406  return false;
407  }
408  if ( !empty( $field['skippable'] ) ) {
409  continue;
410  }
411  if ( $field['type'] === 'button' ) {
412  if ( $button_name !== null ) {
413  $button_name = null;
414  return false;
415  } else {
416  $button_name = $fieldname;
417  }
418  } elseif ( $field['type'] !== 'null' ) {
419  return false;
420  }
421  }
422  return true;
423  }
424 
434  protected function showSuccessPage(
435  $type, $title, $msgname, $injected_html, $extraMessages
436  ) {
437  $out = $this->getOutput();
438  $out->setPageTitle( $title );
439  if ( $msgname ) {
440  $out->addWikiMsg( $msgname, wfEscapeWikiText( $this->getUser()->getName() ) );
441  }
442  if ( $extraMessages ) {
443  $extraMessages = Status::wrap( $extraMessages );
444  $out->addWikiTextAsInterface(
445  $extraMessages->getWikiText( false, false, $this->getLanguage() )
446  );
447  }
448 
449  $out->addHTML( $injected_html );
450 
451  $helper = new LoginHelper( $this->getContext() );
452  $helper->showReturnToPage( $type, $this->mReturnTo, $this->mReturnToQuery, $this->mStickHTTPS );
453  }
454 
470  public function showReturnToPage(
471  $type, $returnTo = '', $returnToQuery = '', $stickHTTPS = false
472  ) {
473  $helper = new LoginHelper( $this->getContext() );
474  $helper->showReturnToPage( $type, $returnTo, $returnToQuery, $stickHTTPS );
475  }
476 
481  protected function setSessionUserForCurrentRequest() {
482  global $wgUser, $wgLang;
483 
485  $localContext = $this->getContext();
486  if ( $context !== $localContext ) {
487  // remove AuthManagerSpecialPage context hack
488  $this->setContext( $context );
489  }
490 
491  $user = $context->getRequest()->getSession()->getUser();
492 
493  $wgUser = $user;
494  $context->setUser( $user );
495 
496  $wgLang = $context->getLanguage();
497  }
498 
513  protected function mainLoginForm( array $requests, $msg = '', $msgtype = 'error' ) {
514  $user = $this->getUser();
515  $out = $this->getOutput();
516 
517  // FIXME how to handle empty $requests - restart, or no form, just an error message?
518  // no form would be better for no session type errors, restart is better when can* fails.
519  if ( !$requests ) {
520  $this->authAction = $this->getDefaultAction( $this->subPage );
521  $this->authForm = null;
522  $requests = AuthManager::singleton()->getAuthenticationRequests( $this->authAction, $user );
523  }
524 
525  // Generic styles and scripts for both login and signup form
526  $out->addModuleStyles( [
527  'mediawiki.ui',
528  'mediawiki.ui.button',
529  'mediawiki.ui.checkbox',
530  'mediawiki.ui.input',
531  'mediawiki.special.userlogin.common.styles'
532  ] );
533  if ( $this->isSignup() ) {
534  // XXX hack pending RL or JS parse() support for complex content messages T27349
535  $out->addJsConfigVars( 'wgCreateacctImgcaptchaHelp',
536  $this->msg( 'createacct-imgcaptcha-help' )->parse() );
537 
538  // Additional styles and scripts for signup form
539  $out->addModules( [
540  'mediawiki.special.userlogin.signup.js'
541  ] );
542  $out->addModuleStyles( [
543  'mediawiki.special.userlogin.signup.styles'
544  ] );
545  } else {
546  // Additional styles for login form
547  $out->addModuleStyles( [
548  'mediawiki.special.userlogin.login.styles'
549  ] );
550  }
551  $out->disallowUserJs(); // just in case...
552 
553  $form = $this->getAuthForm( $requests, $this->authAction, $msg, $msgtype );
554  $form->prepareForm();
555 
556  $submitStatus = Status::newGood();
557  if ( $msg && $msgtype === 'warning' ) {
558  $submitStatus->warning( $msg );
559  } elseif ( $msg && $msgtype === 'error' ) {
560  $submitStatus->fatal( $msg );
561  }
562 
563  // warning header for non-standard workflows (e.g. security reauthentication)
564  if (
565  !$this->isSignup() &&
566  $this->getUser()->isLoggedIn() &&
567  $this->authAction !== AuthManager::ACTION_LOGIN_CONTINUE
568  ) {
569  $reauthMessage = $this->securityLevel ? 'userlogin-reauth' : 'userlogin-loggedin';
570  $submitStatus->warning( $reauthMessage, $this->getUser()->getName() );
571  }
572 
573  $formHtml = $form->getHTML( $submitStatus );
574 
575  $out->addHTML( $this->getPageHtml( $formHtml ) );
576  }
577 
584  protected function getPageHtml( $formHtml ) {
586 
587  $loginPrompt = $this->isSignup() ? '' : Html::rawElement( 'div',
588  [ 'id' => 'userloginprompt' ], $this->msg( 'loginprompt' )->parseAsBlock() );
589  $languageLinks = $wgLoginLanguageSelector ? $this->makeLanguageSelector() : '';
590  $signupStartMsg = $this->msg( 'signupstart' );
591  $signupStart = ( $this->isSignup() && !$signupStartMsg->isDisabled() )
592  ? Html::rawElement( 'div', [ 'id' => 'signupstart' ], $signupStartMsg->parseAsBlock() ) : '';
593  if ( $languageLinks ) {
594  $languageLinks = Html::rawElement( 'div', [ 'id' => 'languagelinks' ],
595  Html::rawElement( 'p', [], $languageLinks )
596  );
597  }
598 
599  $benefitsContainer = '';
600  if ( $this->isSignup() && $this->showExtraInformation() ) {
601  // messages used:
602  // createacct-benefit-icon1 createacct-benefit-head1 createacct-benefit-body1
603  // createacct-benefit-icon2 createacct-benefit-head2 createacct-benefit-body2
604  // createacct-benefit-icon3 createacct-benefit-head3 createacct-benefit-body3
605  $benefitCount = 3;
606  $benefitList = '';
607  for ( $benefitIdx = 1; $benefitIdx <= $benefitCount; $benefitIdx++ ) {
608  $headUnescaped = $this->msg( "createacct-benefit-head$benefitIdx" )->text();
609  $iconClass = $this->msg( "createacct-benefit-icon$benefitIdx" )->text();
610  $benefitList .= Html::rawElement( 'div', [ 'class' => "mw-number-text $iconClass" ],
611  Html::rawElement( 'h3', [],
612  $this->msg( "createacct-benefit-head$benefitIdx" )->escaped()
613  )
614  . Html::rawElement( 'p', [],
615  $this->msg( "createacct-benefit-body$benefitIdx" )->params( $headUnescaped )->escaped()
616  )
617  );
618  }
619  $benefitsContainer = Html::rawElement( 'div', [ 'class' => 'mw-createacct-benefits-container' ],
620  Html::rawElement( 'h2', [], $this->msg( 'createacct-benefit-heading' )->escaped() )
621  . Html::rawElement( 'div', [ 'class' => 'mw-createacct-benefits-list' ],
622  $benefitList
623  )
624  );
625  }
626 
627  $html = Html::rawElement( 'div', [ 'class' => 'mw-ui-container' ],
628  $loginPrompt
629  . $languageLinks
630  . $signupStart
631  . Html::rawElement( 'div', [ 'id' => 'userloginForm' ],
632  $formHtml
633  )
634  . $benefitsContainer
635  );
636 
637  return $html;
638  }
639 
648  protected function getAuthForm( array $requests, $action, $msg = '', $msgType = 'error' ) {
649  global $wgSecureLogin;
650  // FIXME merge this with parent
651 
652  if ( isset( $this->authForm ) ) {
653  return $this->authForm;
654  }
655 
656  $usingHTTPS = $this->getRequest()->getProtocol() === 'https';
657 
658  // get basic form description from the auth logic
659  $fieldInfo = AuthenticationRequest::mergeFieldInfo( $requests );
660  // this will call onAuthChangeFormFields()
661  $formDescriptor = static::fieldInfoToFormDescriptor( $requests, $fieldInfo, $this->authAction );
662  $this->postProcessFormDescriptor( $formDescriptor, $requests );
663 
664  $context = $this->getContext();
665  if ( $context->getRequest() !== $this->getRequest() ) {
666  // We have overridden the request, need to make sure the form uses that too.
667  $context = new DerivativeContext( $this->getContext() );
668  $context->setRequest( $this->getRequest() );
669  }
670  $form = HTMLForm::factory( 'vform', $formDescriptor, $context );
671 
672  $form->addHiddenField( 'authAction', $this->authAction );
673  if ( $this->mLanguage ) {
674  $form->addHiddenField( 'uselang', $this->mLanguage );
675  }
676  $form->addHiddenField( 'force', $this->securityLevel );
677  $form->addHiddenField( $this->getTokenName(), $this->getToken()->toString() );
678  if ( $wgSecureLogin ) {
679  // If using HTTPS coming from HTTP, then the 'fromhttp' parameter must be preserved
680  if ( !$this->isSignup() ) {
681  $form->addHiddenField( 'wpForceHttps', (int)$this->mStickHTTPS );
682  $form->addHiddenField( 'wpFromhttp', $usingHTTPS );
683  }
684  }
685 
686  // set properties of the form itself
687  $form->setAction( $this->getPageTitle()->getLocalURL( $this->getReturnToQueryStringFragment() ) );
688  $form->setName( 'userlogin' . ( $this->isSignup() ? '2' : '' ) );
689  if ( $this->isSignup() ) {
690  $form->setId( 'userlogin2' );
691  }
692 
693  $form->suppressDefaultSubmit();
694 
695  $this->authForm = $form;
696 
697  return $form;
698  }
699 
700  public function onAuthChangeFormFields(
701  array $requests, array $fieldInfo, array &$formDescriptor, $action
702  ) {
703  $coreFieldDescriptors = $this->getFieldDefinitions();
704 
705  // keep the ordering from getCoreFieldDescriptors() where there is no explicit weight
706  foreach ( $coreFieldDescriptors as $fieldName => $coreField ) {
707  $requestField = $formDescriptor[$fieldName] ?? [];
708 
709  // remove everything that is not in the fieldinfo, is not marked as a supplemental field
710  // to something in the fieldinfo, and is not an info field or a submit button
711  if (
712  !isset( $fieldInfo[$fieldName] )
713  && (
714  !isset( $coreField['baseField'] )
715  || !isset( $fieldInfo[$coreField['baseField']] )
716  )
717  && (
718  !isset( $coreField['type'] )
719  || !in_array( $coreField['type'], [ 'submit', 'info' ], true )
720  )
721  ) {
722  $coreFieldDescriptors[$fieldName] = null;
723  continue;
724  }
725 
726  // core message labels should always take priority
727  if (
728  isset( $coreField['label'] )
729  || isset( $coreField['label-message'] )
730  || isset( $coreField['label-raw'] )
731  ) {
732  unset( $requestField['label'], $requestField['label-message'], $coreField['label-raw'] );
733  }
734 
735  $coreFieldDescriptors[$fieldName] += $requestField;
736  }
737 
738  $formDescriptor = array_filter( $coreFieldDescriptors + $formDescriptor );
739  return true;
740  }
741 
748  protected function showExtraInformation() {
749  return $this->authAction !== $this->getContinueAction( $this->authAction )
751  }
752 
757  protected function getFieldDefinitions() {
758  global $wgEmailConfirmToEdit;
759 
760  $isLoggedIn = $this->getUser()->isLoggedIn();
761  $continuePart = $this->isContinued() ? 'continue-' : '';
762  $anotherPart = $isLoggedIn ? 'another-' : '';
763  // @phan-suppress-next-line PhanUndeclaredMethod
764  $expiration = $this->getRequest()->getSession()->getProvider()->getRememberUserDuration();
765  $expirationDays = ceil( $expiration / ( 3600 * 24 ) );
766  $secureLoginLink = '';
767  if ( $this->mSecureLoginUrl ) {
768  $secureLoginLink = Html::element( 'a', [
769  'href' => $this->mSecureLoginUrl,
770  'class' => 'mw-ui-flush-right mw-secure',
771  ], $this->msg( 'userlogin-signwithsecure' )->text() );
772  }
773  $usernameHelpLink = '';
774  if ( !$this->msg( 'createacct-helpusername' )->isDisabled() ) {
775  $usernameHelpLink = Html::rawElement( 'span', [
776  'class' => 'mw-ui-flush-right',
777  ], $this->msg( 'createacct-helpusername' )->parse() );
778  }
779 
780  if ( $this->isSignup() ) {
781  $fieldDefinitions = [
782  'statusarea' => [
783  // used by the mediawiki.special.userlogin.signup.js module for error display
784  // FIXME merge this with HTMLForm's normal status (error) area
785  'type' => 'info',
786  'raw' => true,
787  'default' => Html::element( 'div', [ 'id' => 'mw-createacct-status-area' ] ),
788  'weight' => -105,
789  ],
790  'username' => [
791  'label-raw' => $this->msg( 'userlogin-yourname' )->escaped() . $usernameHelpLink,
792  'id' => 'wpName2',
793  'placeholder-message' => $isLoggedIn ? 'createacct-another-username-ph'
794  : 'userlogin-yourname-ph',
795  ],
796  'mailpassword' => [
797  // create account without providing password, a temporary one will be mailed
798  'type' => 'check',
799  'label-message' => 'createaccountmail',
800  'name' => 'wpCreateaccountMail',
801  'id' => 'wpCreateaccountMail',
802  ],
803  'password' => [
804  'id' => 'wpPassword2',
805  'placeholder-message' => 'createacct-yourpassword-ph',
806  'hide-if' => [ '===', 'wpCreateaccountMail', '1' ],
807  ],
808  'domain' => [],
809  'retype' => [
810  'baseField' => 'password',
811  'type' => 'password',
812  'label-message' => 'createacct-yourpasswordagain',
813  'id' => 'wpRetype',
814  'cssclass' => 'loginPassword',
815  'size' => 20,
816  'validation-callback' => function ( $value, $alldata ) {
817  if ( empty( $alldata['mailpassword'] ) && !empty( $alldata['password'] ) ) {
818  if ( !$value ) {
819  return $this->msg( 'htmlform-required' );
820  } elseif ( $value !== $alldata['password'] ) {
821  return $this->msg( 'badretype' );
822  }
823  }
824  return true;
825  },
826  'hide-if' => [ '===', 'wpCreateaccountMail', '1' ],
827  'placeholder-message' => 'createacct-yourpasswordagain-ph',
828  ],
829  'email' => [
830  'type' => 'email',
831  'label-message' => $wgEmailConfirmToEdit ? 'createacct-emailrequired'
832  : 'createacct-emailoptional',
833  'id' => 'wpEmail',
834  'cssclass' => 'loginText',
835  'size' => '20',
836  // FIXME will break non-standard providers
837  'required' => $wgEmailConfirmToEdit,
838  'validation-callback' => function ( $value, $alldata ) {
839  global $wgEmailConfirmToEdit;
840 
841  // AuthManager will check most of these, but that will make the auth
842  // session fail and this won't, so nicer to do it this way
843  if ( !$value && $wgEmailConfirmToEdit ) {
844  // no point in allowing registration without email when email is
845  // required to edit
846  return $this->msg( 'noemailtitle' );
847  } elseif ( !$value && !empty( $alldata['mailpassword'] ) ) {
848  // cannot send password via email when there is no email address
849  return $this->msg( 'noemailcreate' );
850  } elseif ( $value && !Sanitizer::validateEmail( $value ) ) {
851  return $this->msg( 'invalidemailaddress' );
852  }
853  return true;
854  },
855  'placeholder-message' => 'createacct-' . $anotherPart . 'email-ph',
856  ],
857  'realname' => [
858  'type' => 'text',
859  'help-message' => $isLoggedIn ? 'createacct-another-realname-tip'
860  : 'prefs-help-realname',
861  'label-message' => 'createacct-realname',
862  'cssclass' => 'loginText',
863  'size' => 20,
864  'id' => 'wpRealName',
865  ],
866  'reason' => [
867  // comment for the user creation log
868  'type' => 'text',
869  'label-message' => 'createacct-reason',
870  'cssclass' => 'loginText',
871  'id' => 'wpReason',
872  'size' => '20',
873  'placeholder-message' => 'createacct-reason-ph',
874  ],
875  'createaccount' => [
876  // submit button
877  'type' => 'submit',
878  'default' => $this->msg( 'createacct-' . $anotherPart . $continuePart .
879  'submit' )->text(),
880  'name' => 'wpCreateaccount',
881  'id' => 'wpCreateaccount',
882  'weight' => 100,
883  ],
884  ];
885  } else {
886  $fieldDefinitions = [
887  'username' => [
888  'label-raw' => $this->msg( 'userlogin-yourname' )->escaped() . $secureLoginLink,
889  'id' => 'wpName1',
890  'placeholder-message' => 'userlogin-yourname-ph',
891  ],
892  'password' => [
893  'id' => 'wpPassword1',
894  'placeholder-message' => 'userlogin-yourpassword-ph',
895  ],
896  'domain' => [],
897  'rememberMe' => [
898  // option for saving the user token to a cookie
899  'type' => 'check',
900  'name' => 'wpRemember',
901  'label-message' => $this->msg( 'userlogin-remembermypassword' )
902  ->numParams( $expirationDays ),
903  'id' => 'wpRemember',
904  ],
905  'loginattempt' => [
906  // submit button
907  'type' => 'submit',
908  'default' => $this->msg( 'pt-login-' . $continuePart . 'button' )->text(),
909  'id' => 'wpLoginAttempt',
910  'weight' => 100,
911  ],
912  'linkcontainer' => [
913  // help link
914  'type' => 'info',
915  'cssclass' => 'mw-form-related-link-container mw-userlogin-help',
916  // 'id' => 'mw-userlogin-help', // FIXME HTMLInfoField ignores this
917  'raw' => true,
918  'default' => Html::element( 'a', [
919  'href' => Skin::makeInternalOrExternalUrl( $this->msg( 'helplogin-url' )
920  ->inContentLanguage()
921  ->text() ),
922  ], $this->msg( 'userlogin-helplink2' )->text() ),
923  'weight' => 200,
924  ],
925  // button for ResetPasswordSecondaryAuthenticationProvider
926  'skipReset' => [
927  'weight' => 110,
928  'flags' => [],
929  ],
930  ];
931  }
932 
933  $fieldDefinitions['username'] += [
934  'type' => 'text',
935  'name' => 'wpName',
936  'cssclass' => 'loginText',
937  'size' => 20,
938  // 'required' => true,
939  ];
940  $fieldDefinitions['password'] += [
941  'type' => 'password',
942  // 'label-message' => 'userlogin-yourpassword', // would override the changepassword label
943  'name' => 'wpPassword',
944  'cssclass' => 'loginPassword',
945  'size' => 20,
946  // 'required' => true,
947  ];
948 
949  if ( $this->mEntryError ) {
950  $fieldDefinitions['entryError'] = [
951  'type' => 'info',
952  'default' => Html::rawElement( 'div', [ 'class' => $this->mEntryErrorType . 'box', ],
953  $this->mEntryError ),
954  'raw' => true,
955  'rawrow' => true,
956  'weight' => -100,
957  ];
958  }
959  if ( !$this->showExtraInformation() ) {
960  unset( $fieldDefinitions['linkcontainer'], $fieldDefinitions['signupend'] );
961  }
962  if ( $this->isSignup() && $this->showExtraInformation() ) {
963  // blank signup footer for site customization
964  // uses signupend-https for HTTPS requests if it's not blank, signupend otherwise
965  $signupendMsg = $this->msg( 'signupend' );
966  $signupendHttpsMsg = $this->msg( 'signupend-https' );
967  if ( !$signupendMsg->isDisabled() ) {
968  $usingHTTPS = $this->getRequest()->getProtocol() === 'https';
969  $signupendText = ( $usingHTTPS && !$signupendHttpsMsg->isBlank() )
970  ? $signupendHttpsMsg->parse() : $signupendMsg->parse();
971  $fieldDefinitions['signupend'] = [
972  'type' => 'info',
973  'raw' => true,
974  'default' => Html::rawElement( 'div', [ 'id' => 'signupend' ], $signupendText ),
975  'weight' => 225,
976  ];
977  }
978  }
979  if ( !$this->isSignup() && $this->showExtraInformation() ) {
980  $passwordReset = MediaWikiServices::getInstance()->getPasswordReset();
981  if ( $passwordReset->isAllowed( $this->getUser() )->isGood() ) {
982  $fieldDefinitions['passwordReset'] = [
983  'type' => 'info',
984  'raw' => true,
985  'cssclass' => 'mw-form-related-link-container',
986  'default' => $this->getLinkRenderer()->makeLink(
987  SpecialPage::getTitleFor( 'PasswordReset' ),
988  $this->msg( 'userlogin-resetpassword-link' )->text()
989  ),
990  'weight' => 230,
991  ];
992  }
993 
994  // Don't show a "create account" link if the user can't.
995  if ( $this->showCreateAccountLink() ) {
996  // link to the other action
997  $linkTitle = $this->getTitleFor( $this->isSignup() ? 'Userlogin' : 'CreateAccount' );
998  $linkq = $this->getReturnToQueryStringFragment();
999  // Pass any language selection on to the mode switch link
1000  if ( $this->mLanguage ) {
1001  $linkq .= '&uselang=' . urlencode( $this->mLanguage );
1002  }
1003  $loggedIn = $this->getUser()->isLoggedIn();
1004 
1005  $fieldDefinitions['createOrLogin'] = [
1006  'type' => 'info',
1007  'raw' => true,
1008  'linkQuery' => $linkq,
1009  'default' => function ( $params ) use ( $loggedIn, $linkTitle ) {
1010  return Html::rawElement( 'div',
1011  [ 'id' => 'mw-createaccount' . ( !$loggedIn ? '-cta' : '' ),
1012  'class' => ( $loggedIn ? 'mw-form-related-link-container' : 'mw-ui-vform-field' ) ],
1013  ( $loggedIn ? '' : $this->msg( 'userlogin-noaccount' )->escaped() )
1014  . Html::element( 'a',
1015  [
1016  'id' => 'mw-createaccount-join' . ( $loggedIn ? '-loggedin' : '' ),
1017  'href' => $linkTitle->getLocalURL( $params['linkQuery'] ),
1018  'class' => ( $loggedIn ? '' : 'mw-ui-button' ),
1019  'tabindex' => 100,
1020  ],
1021  $this->msg(
1022  $loggedIn ? 'userlogin-createanother' : 'userlogin-joinproject'
1023  )->text()
1024  )
1025  );
1026  },
1027  'weight' => 235,
1028  ];
1029  }
1030  }
1031 
1032  return $fieldDefinitions;
1033  }
1034 
1044  protected function hasSessionCookie() {
1046 
1047  return $wgDisableCookieCheck || (
1049  $this->getRequest()->getSession()->getId() === (string)$wgInitialSessionId
1050  );
1051  }
1052 
1058  protected function getReturnToQueryStringFragment() {
1059  $returnto = '';
1060  if ( $this->mReturnTo !== '' ) {
1061  $returnto = 'returnto=' . wfUrlencode( $this->mReturnTo );
1062  if ( $this->mReturnToQuery !== '' ) {
1063  $returnto .= '&returntoquery=' . wfUrlencode( $this->mReturnToQuery );
1064  }
1065  }
1066  return $returnto;
1067  }
1068 
1074  private function showCreateAccountLink() {
1075  if ( $this->isSignup() ) {
1076  return true;
1077  } elseif ( MediaWikiServices::getInstance()
1079  ->userHasRight( $this->getUser(), 'createaccount' )
1080  ) {
1081  return true;
1082  } else {
1083  return false;
1084  }
1085  }
1086 
1087  protected function getTokenName() {
1088  return $this->isSignup() ? 'wpCreateaccountToken' : 'wpLoginToken';
1089  }
1090 
1097  protected function makeLanguageSelector() {
1098  $msg = $this->msg( 'loginlanguagelinks' )->inContentLanguage();
1099  if ( $msg->isBlank() ) {
1100  return '';
1101  }
1102  $langs = explode( "\n", $msg->text() );
1103  $links = [];
1104  foreach ( $langs as $lang ) {
1105  $lang = trim( $lang, '* ' );
1106  $parts = explode( '|', $lang );
1107  if ( count( $parts ) >= 2 ) {
1108  $links[] = $this->makeLanguageSelectorLink( $parts[0], trim( $parts[1] ) );
1109  }
1110  }
1111 
1112  return count( $links ) > 0 ? $this->msg( 'loginlanguagelabel' )->rawParams(
1113  $this->getLanguage()->pipeList( $links ) )->escaped() : '';
1114  }
1115 
1124  protected function makeLanguageSelectorLink( $text, $lang ) {
1125  if ( $this->getLanguage()->getCode() == $lang ) {
1126  // no link for currently used language
1127  return htmlspecialchars( $text );
1128  }
1129  $query = [ 'uselang' => $lang ];
1130  if ( $this->mReturnTo !== '' ) {
1131  $query['returnto'] = $this->mReturnTo;
1132  $query['returntoquery'] = $this->mReturnToQuery;
1133  }
1134 
1135  $attr = [];
1136  $targetLanguage = Language::factory( $lang );
1137  $attr['lang'] = $attr['hreflang'] = $targetLanguage->getHtmlCode();
1138 
1139  return $this->getLinkRenderer()->makeKnownLink(
1140  $this->getPageTitle(),
1141  $text,
1142  $attr,
1143  $query
1144  );
1145  }
1146 
1147  protected function getGroupName() {
1148  return 'login';
1149  }
1150 
1155  protected function postProcessFormDescriptor( &$formDescriptor, $requests ) {
1156  // Pre-fill username (if not creating an account, T46775).
1157  if (
1158  isset( $formDescriptor['username'] ) &&
1159  !isset( $formDescriptor['username']['default'] ) &&
1160  !$this->isSignup()
1161  ) {
1162  $user = $this->getUser();
1163  if ( $user->isLoggedIn() ) {
1164  $formDescriptor['username']['default'] = $user->getName();
1165  } else {
1166  $formDescriptor['username']['default'] =
1167  $this->getRequest()->getSession()->suggestLoginUsername();
1168  }
1169  }
1170 
1171  // don't show a submit button if there is nothing to submit (i.e. the only form content
1172  // is other submit buttons, for redirect flows)
1173  if ( !$this->needsSubmitButton( $requests ) ) {
1174  unset( $formDescriptor['createaccount'], $formDescriptor['loginattempt'] );
1175  }
1176 
1177  if ( !$this->isSignup() ) {
1178  // FIXME HACK don't focus on non-empty field
1179  // maybe there should be an autofocus-if similar to hide-if?
1180  if (
1181  isset( $formDescriptor['username'] )
1182  && empty( $formDescriptor['username']['default'] )
1183  && !$this->getRequest()->getCheck( 'wpName' )
1184  ) {
1185  $formDescriptor['username']['autofocus'] = true;
1186  } elseif ( isset( $formDescriptor['password'] ) ) {
1187  $formDescriptor['password']['autofocus'] = true;
1188  }
1189  }
1190 
1191  $this->addTabIndex( $formDescriptor );
1192  }
1193 }
LoginSignupSpecialPage\getTokenName
getTokenName()
Returns the name of the CSRF token (under which it should be found in the POST or GET data).
Definition: LoginSignupSpecialPage.php:1087
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:672
LoginSignupSpecialPage\$mEntryErrorType
$mEntryErrorType
Definition: LoginSignupSpecialPage.php:47
LoginSignupSpecialPage\setRequest
setRequest(array $data, $wasPosted=null)
Override the POST data, GET data from the real request is preserved.
Definition: LoginSignupSpecialPage.php:91
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:792
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:316
LoginSignupSpecialPage\postProcessFormDescriptor
postProcessFormDescriptor(&$formDescriptor, $requests)
Definition: LoginSignupSpecialPage.php:1155
wfCanIPUseHTTPS
wfCanIPUseHTTPS( $ip)
Determine whether the client at a given source IP is likely to be able to access the wiki via HTTPS.
Definition: GlobalFunctions.php:2947
StatusValue\newFatal
static newFatal( $message,... $parameters)
Factory function for fatal errors.
Definition: StatusValue.php:69
LoginSignupSpecialPage\__construct
__construct( $name)
Definition: LoginSignupSpecialPage.php:83
AuthManagerSpecialPage\addTabIndex
addTabIndex(&$formDescriptor)
Adds a sequential tabindex starting from 1 to all form elements.
Definition: AuthManagerSpecialPage.php:605
$response
$response
Definition: opensearch_desc.php:38
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:719
LoginSignupSpecialPage\$mReturnTo
$mReturnTo
Definition: LoginSignupSpecialPage.php:38
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
LoginSignupSpecialPage\showSuccessPage
showSuccessPage( $type, $title, $msgname, $injected_html, $extraMessages)
Show the success page.
Definition: LoginSignupSpecialPage.php:434
LoginSignupSpecialPage\$mReturnToQuery
$mReturnToQuery
Definition: LoginSignupSpecialPage.php:42
true
return true
Definition: router.php:92
LoginSignupSpecialPage\showCreateAccountLink
showCreateAccountLink()
Whether the login/create account form should display a link to the other form (in addition to whateve...
Definition: LoginSignupSpecialPage.php:1074
LoginSignupSpecialPage\load
load( $subPage)
Load data from request.
Definition: LoginSignupSpecialPage.php:122
$wgUseMediaWikiUIEverywhere
$wgUseMediaWikiUIEverywhere
Temporary variable that applies MediaWiki UI wherever it can be supported.
Definition: DefaultSettings.php:3278
wfUrlencode
wfUrlencode( $s)
We want some things to be included as literal characters in our title URLs for prettiness,...
Definition: GlobalFunctions.php:309
SpecialPage\checkPermissions
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
Definition: SpecialPage.php:315
LoginSignupSpecialPage\makeLanguageSelectorLink
makeLanguageSelectorLink( $text, $lang)
Create a language selector link for a particular language Links back to this page preserving type and...
Definition: LoginSignupSpecialPage.php:1124
LoginSignupSpecialPage\beforeExecute
beforeExecute( $subPage)
Gets called before.
Definition: LoginSignupSpecialPage.php:202
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:515
LoginSignupSpecialPage\$mStickHTTPS
$mStickHTTPS
Definition: LoginSignupSpecialPage.php:44
SpecialPage\getTitleFor
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,...
Definition: SpecialPage.php:83
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:749
$success
$success
Definition: NoLocalSettings.php:42
SpecialPage\getName
getName()
Get the name of this Special Page.
Definition: SpecialPage.php:153
AuthManagerSpecialPage
A special page subclass for authentication-related special pages.
Definition: AuthManagerSpecialPage.php:14
LoginSignupSpecialPage\setSessionUserForCurrentRequest
setSessionUserForCurrentRequest()
Replace some globals to make sure the fact that the user has just been logged in is reflected in the ...
Definition: LoginSignupSpecialPage.php:481
LoginHelper
Helper functions for the login form that need to be shared with other special pages (such as CentralA...
Definition: LoginHelper.php:8
LoginSignupSpecialPage\getReturnToQueryStringFragment
getReturnToQueryStringFragment()
Returns a string that can be appended to the URL (without encoding) to preserve the return target.
Definition: LoginSignupSpecialPage.php:1058
AuthManagerSpecialPage\trySubmit
trySubmit()
Attempts to do an authentication step with the submitted data.
Definition: AuthManagerSpecialPage.php:398
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:439
AuthManagerSpecialPage\$subPage
string $subPage
Subpage of the special page.
Definition: AuthManagerSpecialPage.php:35
LoginSignupSpecialPage\$mEntryError
$mEntryError
Definition: LoginSignupSpecialPage.php:46
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:30
$wgLoginLanguageSelector
$wgLoginLanguageSelector
Show a bar of language selection links in the user login and user registration forms; edit the "login...
Definition: DefaultSettings.php:3169
MediaWiki\Logger\LoggerFactory
PSR-3 logger instance factory.
Definition: LoggerFactory.php:45
getPermissionManager
getPermissionManager()
Status\wrap
static wrap( $sv)
Succinct helper method to wrap a StatusValue.
Definition: Status.php:55
LoginSignupSpecialPage\logAuthResult
logAuthResult( $success, $status=null)
Logs to the authmanager-stats channel.
LoginSignupSpecialPage
Holds shared logic for login and account creation pages.
Definition: LoginSignupSpecialPage.php:37
SpecialPage\getFullTitle
getFullTitle()
Return the full title, including $par.
Definition: SpecialPage.php:768
LoginSignupSpecialPage\$proxyAccountCreation
bool $proxyAccountCreation
True if the user if creating an account for someone else.
Definition: LoginSignupSpecialPage.php:59
MediaWiki\Auth\AuthenticationResponse
This is a value object to hold authentication response data.
Definition: AuthenticationResponse.php:37
$wgLang
$wgLang
Definition: Setup.php:881
AuthManagerSpecialPage\loadAuth
loadAuth( $subPage, $authAction=null, $reset=false)
Load or initialize $authAction, $authRequests and $subPage.
Definition: AuthManagerSpecialPage.php:232
LoginSignupSpecialPage\$mPosted
$mPosted
Definition: LoginSignupSpecialPage.php:39
LoginSignupSpecialPage\mainLoginForm
mainLoginForm(array $requests, $msg='', $msgtype='error')
Definition: LoginSignupSpecialPage.php:513
$title
$title
Definition: testCompression.php:34
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:537
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:729
LoginSignupSpecialPage\makeLanguageSelector
makeLanguageSelector()
Produce a bar of links which allow the user to select another language during login/registration but ...
Definition: LoginSignupSpecialPage.php:1097
LoginSignupSpecialPage\hasSessionCookie
hasSessionCookie()
Check if a session cookie is present.
Definition: LoginSignupSpecialPage.php:1044
LoginSignupSpecialPage\loadRequestParameters
loadRequestParameters()
Load basic request parameters for this Special page.
Definition: LoginSignupSpecialPage.php:99
LoginSignupSpecialPage\$mFromHTTP
$mFromHTTP
Definition: LoginSignupSpecialPage.php:45
PROTO_HTTPS
const PROTO_HTTPS
Definition: Defines.php:200
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:692
LoginSignupSpecialPage\$mLoaded
$mLoaded
Definition: LoginSignupSpecialPage.php:49
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:81
LoginSignupSpecialPage\$mAction
$mAction
Definition: LoginSignupSpecialPage.php:40
MediaWiki\Session\SessionManager
This serves as the entry point to the MediaWiki session handling system.
Definition: SessionManager.php:50
LoginSignupSpecialPage\canBypassForm
canBypassForm(&$button_name)
Determine if the login form can be bypassed.
Definition: LoginSignupSpecialPage.php:398
LoginSignupSpecialPage\$mLanguage
$mLanguage
Definition: LoginSignupSpecialPage.php:41
LoginSignupSpecialPage\$mToken
$mToken
Definition: LoginSignupSpecialPage.php:43
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1551
LoginSignupSpecialPage\$authForm
HTMLForm $authForm
Definition: LoginSignupSpecialPage.php:64
LoginSignupSpecialPage\getPageHtml
getPageHtml( $formHtml)
Add page elements which are outside the form.
Definition: LoginSignupSpecialPage.php:584
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:431
AuthManagerSpecialPage\getDefaultAction
getDefaultAction( $subPage)
Get the default action for this special page, if none is given via URL/POST data.
MediaWiki\Auth\AuthManager
This serves as the entry point to the authentication system.
Definition: AuthManager.php:85
AuthManagerSpecialPage\getContinueAction
getContinueAction( $action)
Gets the _CONTINUE version of an action.
Definition: AuthManagerSpecialPage.php:280
$wgEmailConfirmToEdit
$wgEmailConfirmToEdit
Should editors be required to have a validated e-mail address before being allowed to edit?
Definition: DefaultSettings.php:5083
$context
$context
Definition: load.php:45
LoginSignupSpecialPage\isSignup
isSignup()
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:904
$wgDisableCookieCheck
$wgDisableCookieCheck
By default, MediaWiki checks if the client supports cookies during the login process,...
Definition: DefaultSettings.php:6047
$status
return $status
Definition: SyntaxHighlight.php:347
AuthManagerSpecialPage\isActionAllowed
isActionAllowed( $action)
Checks whether AuthManager is ready to perform the action.
Definition: AuthManagerSpecialPage.php:303
LoginSignupSpecialPage\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: LoginSignupSpecialPage.php:1147
LoginSignupSpecialPage\showReturnToPage
showReturnToPage( $type, $returnTo='', $returnToQuery='', $stickHTTPS=false)
Add a "return to" link or redirect to it.
Definition: LoginSignupSpecialPage.php:470
AuthManagerSpecialPage\needsSubmitButton
needsSubmitButton(array $requests)
Returns true if the form built from the given AuthenticationRequests needs a submit button.
Definition: AuthManagerSpecialPage.php:567
SpecialPage\setContext
setContext( $context)
Sets the context this SpecialPage is executed in.
Definition: SpecialPage.php:682
LoginSignupSpecialPage\getPreservedParams
getPreservedParams( $withToken=false)
Returns URL query parameters which can be used to reload the page (or leave and return) while preserv...
Definition: LoginSignupSpecialPage.php:188
AuthManagerSpecialPage\isContinued
isContinued()
Returns true if this is not the first step of the authentication.
Definition: AuthManagerSpecialPage.php:267
AuthManagerSpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: AuthManagerSpecialPage.php:64
Language\factory
static factory( $code)
Get a cached or new language object for a given language code.
Definition: Language.php:217
LoginSignupSpecialPage\$mLoadedRequest
$mLoadedRequest
Definition: LoginSignupSpecialPage.php:50
AuthManagerSpecialPage\getToken
getToken()
Returns the CSRF token.
Definition: AuthManagerSpecialPage.php:625
LoginSignupSpecialPage\$mSecureLoginUrl
$mSecureLoginUrl
Definition: LoginSignupSpecialPage.php:51
LoginSignupSpecialPage\$targetUser
User $targetUser
FIXME another flag for passing data.
Definition: LoginSignupSpecialPage.php:61
LoginSignupSpecialPage\execute
execute( $subPage)
Definition: LoginSignupSpecialPage.php:212
LoginSignupSpecialPage\successfulAction
successfulAction( $direct=false, $extraMessages=null)
LoginSignupSpecialPage\$securityLevel
string $securityLevel
Definition: LoginSignupSpecialPage.php:54
LoginSignupSpecialPage\onAuthChangeFormFields
onAuthChangeFormFields(array $requests, array $fieldInfo, array &$formDescriptor, $action)
Change the form descriptor that determines how a field will look in the authentication form.
Definition: LoginSignupSpecialPage.php:700
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition: ErrorPageError.php:27
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:51
LoginHelper\getValidErrorMessages
static getValidErrorMessages()
Returns an array of all valid error messages.
Definition: LoginHelper.php:37
$wgSecureLogin
$wgSecureLogin
This is to let user authenticate using https when they come from http.
Definition: DefaultSettings.php:4926
LoginSignupSpecialPage\showExtraInformation
showExtraInformation()
Show extra information such as password recovery information, link from login to signup,...
Definition: LoginSignupSpecialPage.php:748
HTMLForm\factory
static factory( $displayFormat,... $arguments)
Construct a HTMLForm object for given display type.
Definition: HTMLForm.php:303
$wgInitialSessionId
$wgInitialSessionId
Definition: Setup.php:810
MediaWiki\Auth\AuthenticationRequest
This is a value object for authentication requests.
Definition: AuthenticationRequest.php:37
LoginSignupSpecialPage\getAuthForm
getAuthForm(array $requests, $action, $msg='', $msgType='error')
Generates a form from the given request.
Definition: LoginSignupSpecialPage.php:648
Skin\makeInternalOrExternalUrl
static makeInternalOrExternalUrl( $name)
If url string starts with http, consider as external URL, else internal.
Definition: Skin.php:1230
LoginSignupSpecialPage\getFieldDefinitions
getFieldDefinitions()
Create a HTMLForm descriptor for the core login fields.
Definition: LoginSignupSpecialPage.php:757
HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition: HTMLForm.php:131
$type
$type
Definition: testCompression.php:48