| 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\MainConfigNames; |
| 25 |
use MediaWiki\Message\Message; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
class CheckBlocksSecondaryAuthenticationProvider extends AbstractSecondaryAuthenticationProvider { |
| 37 |
|
| 38 |
|
| 39 |
protected $blockDisablesLogin = null; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
public function __construct( $params = [] ) { |
| 47 |
if ( isset( $params['blockDisablesLogin'] ) ) { |
| 48 |
$this->blockDisablesLogin = (bool)$params['blockDisablesLogin']; |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
protected function postInitSetup() { |
| 54 |
$this->blockDisablesLogin ??= $this->config->get( MainConfigNames::BlockDisablesLogin ); |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
public function getAuthenticationRequests( $action, array $options ) { |
| 59 |
return []; |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
public function beginSecondaryAuthentication( $user, array $reqs ) { |
| 64 |
if ( !$this->blockDisablesLogin ) { |
| 65 |
return AuthenticationResponse::newAbstain(); |
| 66 |
} |
| 67 |
$block = $user->getBlock(); |
| 68 |
|
| 69 |
|
| 70 |
if ( $block && $block->isSitewide() && $block->isBlocking( $user ) ) { |
| 71 |
return AuthenticationResponse::newFail( |
| 72 |
new Message( 'login-userblocked', [ $user->getName() ] ) |
| 73 |
); |
| 74 |
} else { |
| 75 |
return AuthenticationResponse::newPass(); |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
public function beginSecondaryAccountCreation( $user, $creator, array $reqs ) { |
| 81 |
return AuthenticationResponse::newAbstain(); |
| 82 |
} |
| 83 |
|
| 84 |
} |