MediaWiki master
PasswordAuthenticationRequest.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Auth;
23
25
34 public $password = null;
35
37 public $retype = null;
38
43 public function getFieldInfo() {
44 if ( $this->action === AuthManager::ACTION_REMOVE ) {
45 return [];
46 }
47
48 // for password change it's nice to make extra clear that we are asking for the new password
49 $forNewPassword = $this->action === AuthManager::ACTION_CHANGE;
50 $passwordLabel = $forNewPassword ? 'newpassword' : 'userlogin-yourpassword';
51 $retypeLabel = $forNewPassword ? 'retypenew' : 'yourpasswordagain';
52
53 $ret = [
54 'username' => [
55 'type' => 'string',
56 'label' => wfMessage( 'userlogin-yourname' ),
57 'help' => wfMessage( 'authmanager-username-help' ),
58 ],
59 'password' => [
60 'type' => 'password',
61 'label' => wfMessage( $passwordLabel ),
62 'help' => wfMessage( 'authmanager-password-help' ),
63 'sensitive' => true,
64 ],
65 ];
66
67 switch ( $this->action ) {
70 unset( $ret['username'] );
71 break;
72 }
73
74 if ( $this->action !== AuthManager::ACTION_LOGIN ) {
75 $ret['retype'] = [
76 'type' => 'password',
77 'label' => wfMessage( $retypeLabel ),
78 'help' => wfMessage( 'authmanager-retype-help' ),
79 'sensitive' => true,
80 ];
81 }
82
83 return $ret;
84 }
85
90 public function describeCredentials() {
91 return [
92 'provider' => wfMessage( 'authmanager-provider-password' ),
93 'account' => new RawMessage( '$1', [ $this->username ] ),
94 ];
95 }
96}
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
const ACTION_CHANGE
Change a user's credentials.
const ACTION_REMOVE
Remove a user's credentials.
const ACTION_LOGIN
Log in with an existing (not necessarily local) user.
This is a value object for authentication requests.
This is a value object for authentication requests with a username and password.
describeCredentials()
Describe the credentials represented by this request.This is used on requests returned by Authenticat...
getFieldInfo()
Fetch input field info.This will be used in the AuthManager APIs and web UIs to define API input para...
Variant of the Message class.