3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
22 namespace MediaWiki\Auth
;
24 use MediaWiki\Language\RawMessage
;
27 * This is a value object for authentication requests with a username and password
32 class PasswordAuthenticationRequest
extends AuthenticationRequest
{
33 /** @var string|null */
34 public $password = null;
36 /** @var string|null Password, again */
37 public $retype = null;
43 public function getFieldInfo() {
44 if ( $this->action
=== AuthManager
::ACTION_REMOVE
) {
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';
56 'label' => wfMessage( 'userlogin-yourname' ),
57 'help' => wfMessage( 'authmanager-username-help' ),
61 'label' => wfMessage( $passwordLabel ),
62 'help' => wfMessage( 'authmanager-password-help' ),
67 switch ( $this->action
) {
68 case AuthManager
::ACTION_CHANGE
:
69 case AuthManager
::ACTION_REMOVE
:
70 unset( $ret['username'] );
74 if ( $this->action
!== AuthManager
::ACTION_LOGIN
) {
77 'label' => wfMessage( $retypeLabel ),
78 'help' => wfMessage( 'authmanager-retype-help' ),
90 public function describeCredentials() {
92 'provider' => wfMessage( 'authmanager-provider-password' ),
93 'account' => new RawMessage( '$1', [ $this->username
] ),