| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
namespace MediaWiki\Auth; |
| 23 |
|
| 24 |
use MediaWiki\Language\RawMessage; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
class PasswordAuthenticationRequest extends AuthenticationRequest { |
| 33 |
|
| 34 |
public $password = null; |
| 35 |
|
| 36 |
|
| 37 |
public $retype = null; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public function getFieldInfo() { |
| 44 |
if ( $this->action === AuthManager::ACTION_REMOVE ) { |
| 45 |
return []; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 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 ) { |
| 68 |
case AuthManager::ACTION_CHANGE: |
| 69 |
case AuthManager::ACTION_REMOVE: |
| 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 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
public function describeCredentials() { |
| 91 |
return [ |
| 92 |
'provider' => wfMessage( 'authmanager-provider-password' ), |
| 93 |
'account' => new RawMessage( '$1', [ $this->username ] ), |
| 94 |
]; |
| 95 |
} |
| 96 |
} |