MediaWiki master
CheckBlocksSecondaryAuthenticationProvider.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Auth;
8
11
22
24 protected $blockDisablesLogin = null;
25
31 public function __construct( $params = [] ) {
32 if ( isset( $params['blockDisablesLogin'] ) ) {
33 $this->blockDisablesLogin = (bool)$params['blockDisablesLogin'];
34 }
35 }
36
38 protected function postInitSetup() {
39 $this->blockDisablesLogin ??= $this->config->get( MainConfigNames::BlockDisablesLogin );
40 }
41
43 public function getAuthenticationRequests( $action, array $options ) {
44 return [];
45 }
46
48 public function beginSecondaryAuthentication( $user, array $reqs ) {
49 if ( !$this->blockDisablesLogin ) {
51 }
52 $block = $user->getBlock();
53 // Ignore IP blocks and partial blocks, $wgBlockDisablesLogin was meant for
54 // blocks banning specific users.
55 if ( $block && $block->isSitewide() && $block->isBlocking( $user ) ) {
57 new Message( 'login-userblocked', [ $user->getName() ] )
58 );
59 } else {
61 }
62 }
63
65 public function beginSecondaryAccountCreation( $user, $creator, array $reqs ) {
67 }
68
69}
A base class that implements some of the boilerplate for a SecondaryAuthenticationProvider.
static newFail(Message $msg, array $failReasons=[])
Check if the user is blocked, and prevent authentication if so.
beginSecondaryAccountCreation( $user, $creator, array $reqs)
Start an account creation flow.There is no guarantee this will be called in a successful account crea...
getAuthenticationRequests( $action, array $options)
Return the applicable list of AuthenticationRequests.Possible values for $action depend on whether th...
beginSecondaryAuthentication( $user, array $reqs)
Start an authentication flow.Note that this may be called for a user even if beginSecondaryAccountCre...
postInitSetup()
A provider can override this to do any necessary setup after init() is called.1.37 to override
A class containing constants representing the names of configuration variables.
const BlockDisablesLogin
Name constant for the BlockDisablesLogin setting, for use with Config::get()
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:144