MediaWiki  master
TemporaryPasswordAuthenticationRequest.php
Go to the documentation of this file.
1 <?php
22 namespace MediaWiki\Auth;
23 
26 
35  public $password;
36 
38  public $mailpassword = false;
39 
41  public $caller;
42 
47  public function getFieldInfo() {
48  return [
49  'mailpassword' => [
50  'type' => 'checkbox',
51  'label' => wfMessage( 'createaccountmail' ),
52  'help' => wfMessage( 'createaccountmail-help' ),
53  ],
54  ];
55  }
56 
61  public function __construct( $password = null ) {
62  $this->password = $password;
63  if ( $password ) {
64  $this->mailpassword = true;
65  }
66  }
67 
72  public static function newRandom() {
73  $config = MediaWikiServices::getInstance()->getMainConfig();
74 
75  // get the min password length
78  foreach ( $policy['policies'] as $p ) {
79  foreach ( [ 'MinimalPasswordLength', 'MinimumPasswordLengthToLogin' ] as $check ) {
80  $minLength = max( $minLength, $p[$check]['value'] ?? $p[$check] ?? 0 );
81  }
82  }
83 
85 
86  return new self( $password );
87  }
88 
93  public static function newInvalid() {
94  $request = new self( null );
95  return $request;
96  }
97 
102  public function describeCredentials() {
103  return [
104  'provider' => wfMessage( 'authmanager-provider-temporarypassword' ),
105  'account' => new \RawMessage( '$1', [ $this->username ] ),
106  ] + parent::describeCredentials();
107  }
108 
109 }
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
This is a value object for authentication requests.
This represents the intention to set a temporary password for the user.
static newRandom()
Return an instance with a new, random password.
describeCredentials()
Describe the credentials represented by this request.This is used on requests returned by Authenticat...
static newInvalid()
Return an instance with an invalid password.
getFieldInfo()
Fetch input field info.The field info is an associative array mapping field names to info arrays....
A class containing constants representing the names of configuration variables.
const MinimalPasswordLength
Name constant for the MinimalPasswordLength setting, for use with Config::get()
const PasswordPolicy
Name constant for the PasswordPolicy setting, for use with Config::get()
MediaWikiServices is the service locator for the application scope of MediaWiki.
static getInstance()
Returns the global default instance of the top level service locator.
Config $config
Definition: MediaWiki.php:44
static generateRandomPasswordString(int $minLength=10)
Generate a random string suitable for a password.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".