blockDisablesLogin = (bool)$params['blockDisablesLogin']; } } public function setConfig( Config $config ) { parent::setConfig( $config ); if ( $this->blockDisablesLogin === null ) { $this->blockDisablesLogin = $this->config->get( 'BlockDisablesLogin' ); } } public function getAuthenticationRequests( $action, array $options ) { return []; } public function beginSecondaryAuthentication( $user, array $reqs ) { // @TODO Partial blocks should not prevent the user from logging in. // see: https://phabricator.wikimedia.org/T208895 if ( !$this->blockDisablesLogin ) { return AuthenticationResponse::newAbstain(); } elseif ( $user->getBlock() ) { return AuthenticationResponse::newFail( new \Message( 'login-userblocked', [ $user->getName() ] ) ); } else { return AuthenticationResponse::newPass(); } } public function beginSecondaryAccountCreation( $user, $creator, array $reqs ) { return AuthenticationResponse::newAbstain(); } public function testUserForCreation( $user, $autocreate, array $options = [] ) { $block = $user->isBlockedFromCreateAccount(); if ( $block ) { $formatter = MediaWikiServices::getInstance()->getBlockErrorFormatter(); $language = \RequestContext::getMain()->getUser()->isSafeToLoad() ? \RequestContext::getMain()->getLanguage() : MediaWikiServices::getInstance()->getContentLanguage(); $ip = $this->manager->getRequest()->getIP(); return StatusValue::newFatal( $formatter->getMessage( $block, $user, $language, $ip ) ); } else { return StatusValue::newGood(); } } }