use MediaWiki\Auth\Throttler;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\Session\SessionManager;
-use Psr\Log\LogLevel;
/**
* Holds shared logic for login and account creation pages.
// add pre/post text
// header used by ConfirmEdit, CondfirmAccount, Persona, WikimediaIncubator, SemanticSignup
// should be above the error message but HTMLForm doesn't support that
- $form->addHeaderText( $fakeTemplate->html( 'header' ) );
+ $form->addHeaderText( $fakeTemplate->get( 'header' ) );
// FIXME the old form used this for error/warning messages which does not play well with
// HTMLForm (maybe it could with a subclass?); for now only display it for signups
}
// header used by MobileFrontend
- $form->addHeaderText( $fakeTemplate->html( 'formheader' ) );
+ $form->addHeaderText( $fakeTemplate->get( 'formheader' ) );
// blank signup footer for site customization
if ( $this->isSignup() && $this->showExtraInformation() ) {
'rememberMe' => [
// option for saving the user token to a cookie
'type' => 'check',
+ 'name' => 'wpRemember',
'label-message' => $this->msg( 'userlogin-remembermypassword' )
->numParams( $expirationDays ),
'id' => 'wpRemember',
'loginattempt' => [
// submit button
'type' => 'submit',
- 'name' => 'wpRemember',
'default' => $this->msg( 'pt-login-' . $continuePart . 'button' )->text(),
'id' => 'wpLoginAttempt',
'weight' => 100,
}
}
-/**
- * A horrible hack to handle AuthManager's feature flag. For other special pages this is done in
- * SpecialPageFactory, but LoginForm is used directly by some extensions. Will be killed as soon
- * as AuthManager is stable.
- */
-class LoginForm extends SpecialPage {
- private $realLoginForm;
-
- public function __construct( $request = null ) {
- global $wgDisableAuthManager;
- if ( $wgDisableAuthManager ) {
- $this->realLoginForm = new LoginFormPreAuthManager( $request );
- } else {
- $this->realLoginForm = new LoginFormAuthManager( $request );
- }
- }
-
- // proxy everything
-
- public function __get( $name ) {
- return $this->realLoginForm->$name;
- }
-
- public function __set( $name, $value ) {
- $this->realLoginForm->$name = $value;
- }
-
- public function __call( $name, $args ) {
- return call_user_func_array( [ $this->realLoginForm, $name ], $args );
- }
-
- public static function __callStatic( $name, $args ) {
- global $wgDisableAuthManager;
- return call_user_func_array( [ $wgDisableAuthManager ? LoginFormPreAuthManager::class
- : LoginFormAuthManager::class, $name ], $args );
- }
-
- // all public SpecialPage methods need to be proxied explicitly
-
- public function getName() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getRestriction() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function isListed() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function setListed( $listed ) {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function listed( $x = null ) {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function isIncludable() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function including( $x = null ) {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getLocalName() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function isExpensive() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function isCached() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function isRestricted() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function userCanExecute( User $user ) {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function displayRestrictionError() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function checkPermissions() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function checkReadOnly() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function requireLogin(
- $reasonMsg = 'exception-nologin-text', $titleMsg = 'exception-nologin'
- ) {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function prefixSearchSubpages( $search, $limit, $offset ) {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function execute( $subPage ) {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getDescription() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- function getTitle( $subpage = false ) {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- function getPageTitle( $subpage = false ) {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function setContext( $context ) {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getContext() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getRequest() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getOutput() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getUser() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getSkin() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getLanguage() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getConfig() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getFullTitle() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function getFinalGroupName() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
- public function doesWrites() {
- return call_user_func_array( [ $this->realLoginForm, __FUNCTION__ ], func_get_args() );
- }
-
- // no way to proxy constants and static properties
-
- const SUCCESS = 0;
- const NO_NAME = 1;
- const ILLEGAL = 2;
- const WRONG_PLUGIN_PASS = 3;
- const NOT_EXISTS = 4;
- const WRONG_PASS = 5;
- const EMPTY_PASS = 6;
- const RESET_PASS = 7;
- const ABORTED = 8;
- const CREATE_BLOCKED = 9;
- const THROTTLED = 10;
- const USER_BLOCKED = 11;
- const NEED_TOKEN = 12;
- const WRONG_TOKEN = 13;
- const USER_MIGRATED = 14;
-
- public static $statusCodes = [
- self::SUCCESS => 'success',
- self::NO_NAME => 'no_name',
- self::ILLEGAL => 'illegal',
- self::WRONG_PLUGIN_PASS => 'wrong_plugin_pass',
- self::NOT_EXISTS => 'not_exists',
- self::WRONG_PASS => 'wrong_pass',
- self::EMPTY_PASS => 'empty_pass',
- self::RESET_PASS => 'reset_pass',
- self::ABORTED => 'aborted',
- self::CREATE_BLOCKED => 'create_blocked',
- self::THROTTLED => 'throttled',
- self::USER_BLOCKED => 'user_blocked',
- self::NEED_TOKEN => 'need_token',
- self::WRONG_TOKEN => 'wrong_token',
- self::USER_MIGRATED => 'user_migrated',
- ];
-
- public static $validErrorMessages = [
- 'exception-nologin-text',
- 'watchlistanontext',
- 'changeemail-no-info',
- 'resetpass-no-info',
- 'confirmemail_needlogin',
- 'prefsnologintext2',
- ];
-}
-
/**
* LoginForm as a special page has been replaced by SpecialUserLogin and SpecialCreateAccount,
* but some extensions called its public methods directly, so the class is retained as a
* B/C wrapper. Anything that used it before should use AuthManager instead.
*/
-class LoginFormAuthManager extends SpecialPage {
+class LoginForm extends SpecialPage {
const SUCCESS = 0;
const NO_NAME = 1;
const ILLEGAL = 2;