MediaWiki master
MediaWiki\Specials\Helpers\LoginHelper Class Reference

Helper functions for the login form that need to be shared with other special pages (such as CentralAuth's SpecialCentralLogin). More...

Inherits MediaWiki\Context\ContextSource.

Collaboration diagram for MediaWiki\Specials\Helpers\LoginHelper:

Public Member Functions

 __construct (IContextSource $context)
 
 getDisplayMode ()
 Get the display mode for the login form.
 
 getPreservedParams (array $options)
 Returns an URL query parameter array which contains state information that should be preserved when navigating to the next (or first) step of a login or signup process.
 
 isDisplayModePopup ()
 Check if the current display mode is popup.
 
 showReturnToPage ( $type, $returnTo='', $returnToQuery='', $stickHTTPS=false, $returnToAnchor='')
 Show a return link or redirect to it.
 
- Public Member Functions inherited from MediaWiki\Context\ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage().
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID.
 
 getActionName ()
 Get the action name for the current web request.
 
 getAuthority ()
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object.
 
 getCsrfTokenSet ()
 Get a repository to obtain and match CSRF tokens.
 
 getLanguage ()
 
 getLanguageCode ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object.
 
 msg ( $key,... $params)
 Get a Message object with context set Parameters are the same as wfMessage()
 
 setContext (IContextSource $context)
 

Static Public Member Functions

static getValidErrorMessages ()
 Returns an array of all error and warning messages that can be displayed on Special:UserLogin or Special:CreateAccount through the ?error or ?warning GET parameters.
 

Public Attributes

const DISPLAY_MODE_DEFAULT = self::DISPLAY_MODE_PAGE
 Default display mode.
 
const DISPLAY_MODE_PAGE = 'page'
 Display mode for full page.
 
const DISPLAY_MODE_PARAM_NAME = 'display'
 URL parameter for display mode.
 
const DISPLAY_MODE_POPUP = 'popup'
 Display mode for popup window.
 

Detailed Description

Helper functions for the login form that need to be shared with other special pages (such as CentralAuth's SpecialCentralLogin).

Stability: newable
Since
1.27

Definition at line 18 of file LoginHelper.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Specials\Helpers\LoginHelper::__construct ( IContextSource $context)

Definition at line 53 of file LoginHelper.php.

Member Function Documentation

◆ getDisplayMode()

MediaWiki\Specials\Helpers\LoginHelper::getDisplayMode ( )

Get the display mode for the login form.

The display mode is determined by the 'display' request parameter. If not set or invalid, defaults to page mode.

Returns
string 'page' or 'popup'

Definition at line 131 of file LoginHelper.php.

◆ getPreservedParams()

MediaWiki\Specials\Helpers\LoginHelper::getPreservedParams ( array $options)

Returns an URL query parameter array which contains state information that should be preserved when navigating to the next (or first) step of a login or signup process.

These parameters can be included in links / forms to preserve things like the layout or the language, which are normally preserved via user preferences, but during login/signup, probably not.

This is basically a wrapper around the AuthPreserveQueryParams hook to work around the fact that there is no easy way to add hook handlers in core.

Parameters
array$options
  • reset (bool, default false): Reset the authentication process, i.e. omit parameters which are related to continuing in-progress authentication. This is used e.g. in the link for switching from the login form to the signup form.
  • params (array): Additional preserved parameters.
  • request (WebRequest): The request object. Can be omitted to use LoginHelper's context object.
Since
1.47

Definition at line 186 of file LoginHelper.php.

References MediaWiki\Specials\Helpers\getHookRunner().

◆ getValidErrorMessages()

static MediaWiki\Specials\Helpers\LoginHelper::getValidErrorMessages ( )
static

Returns an array of all error and warning messages that can be displayed on Special:UserLogin or Special:CreateAccount through the ?error or ?warning GET parameters.

Special:UserLogin and Special:CreateAccount can show an error or warning message on the form when coming from another page using the aforementioned GET parameters.

Further keys can be added by the LoginFormValidErrorMessages hook. If a message key is not in this list, then no redirect will be performed to Special:UserLogin or Special:CreateAccount.

Returns
string[]
See also
LoginHelper::$validErrorMessages

Definition at line 49 of file LoginHelper.php.

◆ isDisplayModePopup()

MediaWiki\Specials\Helpers\LoginHelper::isDisplayModePopup ( )

Check if the current display mode is popup.

Returns
bool True if display mode is popup

Definition at line 143 of file LoginHelper.php.

◆ showReturnToPage()

MediaWiki\Specials\Helpers\LoginHelper::showReturnToPage ( $type,
$returnTo = '',
$returnToQuery = '',
$stickHTTPS = false,
$returnToAnchor = '' )

Show a return link or redirect to it.

Extensions can change where the link should point or inject content into the page (which will change it from redirect to link mode).

Parameters
string$typeOne of the following:
  • error: display a return to link ignoring $wgRedirectOnLogin
  • success: display a return to link using $wgRedirectOnLogin if needed
  • successredirect: send an HTTP redirect using $wgRedirectOnLogin if needed
  • signup: used during signup, functionally identical to 'success'
string$returnToTitle of page to return to. Overridden by $wgRedirectOnLogin when that is set (and $type is not 'error').
array | string$returnToQueryQuery parameters to return to.
bool$stickHTTPSKeep redirect link on HTTPS. Ignored (treated as true) if $wgForceHTTPS is true.
string$returnToAnchorA string to append to the URL, presumed to be either a fragment including the leading hash or an empty string.

Definition at line 75 of file LoginHelper.php.

References MediaWiki\MainConfigNames\ForceHTTPS, MediaWiki\Specials\Helpers\getConfig(), MediaWiki\Specials\Helpers\getHookRunner(), PROTO_HTTP, PROTO_HTTPS, PROTO_RELATIVE, MediaWiki\MainConfigNames\RedirectOnLogin, MediaWiki\MainConfigNames\SecureLogin, and wfCgiToArray().

Member Data Documentation

◆ DISPLAY_MODE_DEFAULT

const MediaWiki\Specials\Helpers\LoginHelper::DISPLAY_MODE_DEFAULT = self::DISPLAY_MODE_PAGE

Default display mode.

Definition at line 28 of file LoginHelper.php.

◆ DISPLAY_MODE_PAGE

const MediaWiki\Specials\Helpers\LoginHelper::DISPLAY_MODE_PAGE = 'page'

Display mode for full page.

Definition at line 25 of file LoginHelper.php.

◆ DISPLAY_MODE_PARAM_NAME

const MediaWiki\Specials\Helpers\LoginHelper::DISPLAY_MODE_PARAM_NAME = 'display'

URL parameter for display mode.

Definition at line 31 of file LoginHelper.php.

◆ DISPLAY_MODE_POPUP

const MediaWiki\Specials\Helpers\LoginHelper::DISPLAY_MODE_POPUP = 'popup'

Display mode for popup window.

Definition at line 22 of file LoginHelper.php.


The documentation for this class was generated from the following file: