Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / auth / PasswordAuthenticationRequest.php
blobb492305365085efa05f4c68388d8d8a53f8ad497
1 <?php
2 /**
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
18 * @file
19 * @ingroup Auth
22 namespace MediaWiki\Auth;
24 use MediaWiki\Language\RawMessage;
26 /**
27 * This is a value object for authentication requests with a username and password
28 * @stable to extend
29 * @ingroup Auth
30 * @since 1.27
32 class PasswordAuthenticationRequest extends AuthenticationRequest {
33 /** @var string|null */
34 public $password = null;
36 /** @var string|null Password, again */
37 public $retype = null;
39 /**
40 * @inheritDoc
41 * @stable to override
43 public function getFieldInfo() {
44 if ( $this->action === AuthManager::ACTION_REMOVE ) {
45 return [];
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';
53 $ret = [
54 'username' => [
55 'type' => 'string',
56 'label' => wfMessage( 'userlogin-yourname' ),
57 'help' => wfMessage( 'authmanager-username-help' ),
59 'password' => [
60 'type' => 'password',
61 'label' => wfMessage( $passwordLabel ),
62 'help' => wfMessage( 'authmanager-password-help' ),
63 'sensitive' => true,
67 switch ( $this->action ) {
68 case AuthManager::ACTION_CHANGE:
69 case AuthManager::ACTION_REMOVE:
70 unset( $ret['username'] );
71 break;
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,
83 return $ret;
86 /**
87 * @inheritDoc
88 * @stable to override
90 public function describeCredentials() {
91 return [
92 'provider' => wfMessage( 'authmanager-provider-password' ),
93 'account' => new RawMessage( '$1', [ $this->username ] ),