MediaWiki REL1_32
PasswordAuthenticationRequest.php
Go to the documentation of this file.
1<?php
22namespace 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}
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.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition hooks.txt:2054
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services