MediaWiki  master
RememberMeAuthenticationRequest.php
Go to the documentation of this file.
1 <?php
22 namespace MediaWiki\Auth;
23 
26 
35 
37 
39  protected $expiration = null;
40 
42  public $rememberMe = false;
43 
47  public function __construct() {
49  $provider = SessionManager::getGlobalSession()->getProvider();
50  '@phan-var SessionProvider $provider';
51  $this->expiration = $provider->getRememberUserDuration();
52  }
53 
58  public function getFieldInfo() {
59  if ( !$this->expiration ) {
60  return [];
61  }
62 
63  $expirationDays = ceil( $this->expiration / ( 3600 * 24 ) );
64  return [
65  'rememberMe' => [
66  'type' => 'checkbox',
67  'label' => wfMessage( 'userlogin-remembermypassword' )->numParams( $expirationDays ),
68  'help' => wfMessage( 'authmanager-userlogin-remembermypassword-help' ),
69  'optional' => true,
70  'skippable' => true,
71  ]
72  ];
73  }
74 }
MediaWiki\Auth\RememberMeAuthenticationRequest\$expiration
int $expiration
How long the user will be remembered, in seconds.
Definition: RememberMeAuthenticationRequest.php:39
MediaWiki\Auth\AuthenticationRequest\OPTIONAL
const OPTIONAL
Indicates that the request is not required for authentication to proceed.
Definition: AuthenticationRequest.php:41
MediaWiki\Auth\RememberMeAuthenticationRequest\getFieldInfo
getFieldInfo()
Fetch input field info.The field info is an associative array mapping field names to info arrays....
Definition: RememberMeAuthenticationRequest.php:58
MediaWiki\Auth\RememberMeAuthenticationRequest\__construct
__construct()
Stable to call.
Definition: RememberMeAuthenticationRequest.php:47
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1220
MediaWiki\Auth\RememberMeAuthenticationRequest\$required
$required
Definition: RememberMeAuthenticationRequest.php:36
MediaWiki\Auth\RememberMeAuthenticationRequest\$rememberMe
bool $rememberMe
Definition: RememberMeAuthenticationRequest.php:42
MediaWiki\Session\SessionProvider
A SessionProvider provides SessionInfo and support for Session.
Definition: SessionProvider.php:81
MediaWiki\Session\SessionManager\getGlobalSession
static getGlobalSession()
Get the "global" session.
Definition: SessionManager.php:114
MediaWiki\Session\SessionManager
This serves as the entry point to the MediaWiki session handling system.
Definition: SessionManager.php:52
MediaWiki\Auth\RememberMeAuthenticationRequest
This is an authentication request added by AuthManager to show a "remember me" checkbox.
Definition: RememberMeAuthenticationRequest.php:34
MediaWiki\Auth
Definition: AbstractAuthenticationProvider.php:22
MediaWiki\Auth\AuthenticationRequest
This is a value object for authentication requests.
Definition: AuthenticationRequest.php:38