MediaWiki  1.34.0
PasswordAuthenticationRequest.php
Go to the documentation of this file.
1 <?php
22 namespace MediaWiki\Auth;
23 
31  public $password = null;
32 
34  public $retype = null;
35 
36  public function getFieldInfo() {
37  if ( $this->action === AuthManager::ACTION_REMOVE ) {
38  return [];
39  }
40 
41  // for password change it's nice to make extra clear that we are asking for the new password
42  $forNewPassword = $this->action === AuthManager::ACTION_CHANGE;
43  $passwordLabel = $forNewPassword ? 'newpassword' : 'userlogin-yourpassword';
44  $retypeLabel = $forNewPassword ? 'retypenew' : 'yourpasswordagain';
45 
46  $ret = [
47  'username' => [
48  'type' => 'string',
49  'label' => wfMessage( 'userlogin-yourname' ),
50  'help' => wfMessage( 'authmanager-username-help' ),
51  ],
52  'password' => [
53  'type' => 'password',
54  'label' => wfMessage( $passwordLabel ),
55  'help' => wfMessage( 'authmanager-password-help' ),
56  'sensitive' => true,
57  ],
58  ];
59 
60  switch ( $this->action ) {
63  unset( $ret['username'] );
64  break;
65  }
66 
67  if ( $this->action !== AuthManager::ACTION_LOGIN ) {
68  $ret['retype'] = [
69  'type' => 'password',
70  'label' => wfMessage( $retypeLabel ),
71  'help' => wfMessage( 'authmanager-retype-help' ),
72  'sensitive' => true,
73  ];
74  }
75 
76  return $ret;
77  }
78 
79  public function describeCredentials() {
80  return [
81  'provider' => wfMessage( 'authmanager-provider-password' ),
82  'account' => new \RawMessage( '$1', [ $this->username ] ),
83  ];
84  }
85 }
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1264
MediaWiki\Auth\PasswordAuthenticationRequest
This is a value object for authentication requests with a username and password.
Definition: PasswordAuthenticationRequest.php:29
MediaWiki\Auth\PasswordAuthenticationRequest\getFieldInfo
getFieldInfo()
Fetch input field info.
Definition: PasswordAuthenticationRequest.php:36
MediaWiki\Auth\AuthManager\ACTION_CHANGE
const ACTION_CHANGE
Change a user's credentials.
Definition: AuthManager.php:105
MediaWiki\Auth\AuthManager\ACTION_REMOVE
const ACTION_REMOVE
Remove a user's credentials.
Definition: AuthManager.php:107
MediaWiki\Auth\PasswordAuthenticationRequest\$retype
string $retype
Password, again.
Definition: PasswordAuthenticationRequest.php:34
MediaWiki\Auth\AuthManager\ACTION_LOGIN
const ACTION_LOGIN
Log in with an existing (not necessarily local) user.
Definition: AuthManager.php:87
MediaWiki\Auth\PasswordAuthenticationRequest\$password
string $password
Password.
Definition: PasswordAuthenticationRequest.php:31
MediaWiki\Auth
Definition: AbstractAuthenticationProvider.php:22
MediaWiki\Auth\AuthenticationRequest
This is a value object for authentication requests.
Definition: AuthenticationRequest.php:37
MediaWiki\Auth\PasswordAuthenticationRequest\describeCredentials
describeCredentials()
Describe the credentials represented by this request.
Definition: PasswordAuthenticationRequest.php:79