MediaWiki REL1_37
PasswordAuthenticationRequest.php
Go to the documentation of this file.
1<?php
22namespace 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( $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.The field info is an associative array mapping field names to info arrays....