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