MediaWiki  master
TemporaryPasswordAuthenticationRequest.php
Go to the documentation of this file.
1 <?php
22 namespace MediaWiki\Auth;
23 
25 
34  public $password;
35 
37  public $mailpassword = false;
38 
40  public $caller;
41 
46  public function getFieldInfo() {
47  return [
48  'mailpassword' => [
49  'type' => 'checkbox',
50  'label' => wfMessage( 'createaccountmail' ),
51  'help' => wfMessage( 'createaccountmail-help' ),
52  ],
53  ];
54  }
55 
60  public function __construct( $password = null ) {
61  $this->password = $password;
62  if ( $password ) {
63  $this->mailpassword = true;
64  }
65  }
66 
71  public static function newRandom() {
72  $config = MediaWikiServices::getInstance()->getMainConfig();
73 
74  // get the min password length
75  $minLength = $config->get( 'MinimalPasswordLength' );
76  $policy = $config->get( 'PasswordPolicy' );
77  foreach ( $policy['policies'] as $p ) {
78  foreach ( [ 'MinimalPasswordLength', 'MinimumPasswordLengthToLogin' ] as $check ) {
79  $minLength = max( $minLength, $p[$check]['value'] ?? $p[$check] ?? 0 );
80  }
81  }
82 
84 
85  return new self( $password );
86  }
87 
92  public static function newInvalid() {
93  $request = new self( null );
94  return $request;
95  }
96 
101  public function describeCredentials() {
102  return [
103  'provider' => wfMessage( 'authmanager-provider-temporarypassword' ),
104  'account' => new \RawMessage( '$1', [ $this->username ] ),
105  ] + parent::describeCredentials();
106  }
107 
108 }
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:154
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\__construct
__construct( $password=null)
Stable to call.
Definition: TemporaryPasswordAuthenticationRequest.php:60
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1219
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
Definition: MediaWikiServices.php:185
Config\get
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\getFieldInfo
getFieldInfo()
Fetch input field info.The field info is an associative array mapping field names to info arrays....
Definition: TemporaryPasswordAuthenticationRequest.php:46
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\$password
string null $password
Temporary password.
Definition: TemporaryPasswordAuthenticationRequest.php:34
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\newInvalid
static newInvalid()
Return an instance with an invalid password.
Definition: TemporaryPasswordAuthenticationRequest.php:92
PasswordFactory\generateRandomPasswordString
static generateRandomPasswordString(int $minLength=10)
Generate a random string suitable for a password.
Definition: PasswordFactory.php:226
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\$caller
string $caller
Username or IP address of the caller.
Definition: TemporaryPasswordAuthenticationRequest.php:40
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\$mailpassword
bool $mailpassword
Email password to the user.
Definition: TemporaryPasswordAuthenticationRequest.php:37
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\describeCredentials
describeCredentials()
Describe the credentials represented by this request.This is used on requests returned by Authenticat...
Definition: TemporaryPasswordAuthenticationRequest.php:101
MediaWiki\$config
Config $config
Definition: MediaWiki.php:42
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest
This represents the intention to set a temporary password for the user.
Definition: TemporaryPasswordAuthenticationRequest.php:32
MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\newRandom
static newRandom()
Return an instance with a new, random password.
Definition: TemporaryPasswordAuthenticationRequest.php:71
MediaWiki\Auth
Definition: AbstractAuthenticationProvider.php:22
MediaWiki\Auth\AuthenticationRequest
This is a value object for authentication requests.
Definition: AuthenticationRequest.php:38