MediaWiki
REL1_34
SetIsEnabled.php
Go to the documentation of this file.
1
<?php
2
3
namespace
MediaWiki\Extension\OATHAuth\Hook\TwoFactorIsEnabled
;
4
5
use
MediaWiki\Extension\OATHAuth\OATHUser
;
6
use
MediaWiki\MediaWikiServices
;
7
use
RequestContext
;
8
9
class
SetIsEnabled
{
13
protected
$authUser
;
14
18
protected
$isEnabled
;
19
24
public
static
function
callback
( &
$isEnabled
) {
25
$userRepo =
MediaWikiServices::getInstance
()->getService(
'OATHUserRepository'
);
26
$authUser
= $userRepo->findByUser( RequestContext::getMain()->
getUser
() );
27
$handler =
new
static
(
$authUser
,
$isEnabled
);
28
return
$handler->execute();
29
}
30
36
protected
function
__construct
(
$authUser
, &
$isEnabled
) {
37
$this->authUser =
$authUser
;
38
$this->isEnabled = &
$isEnabled
;
39
}
40
41
protected
function
execute
() {
42
if
( $this->authUser && $this->authUser->getModule() !==
null
) {
43
$this->isEnabled =
true
;
44
# This two-factor extension is enabled by the user,
45
# we don't need to check others.
46
return
false
;
47
}
else
{
48
$this->isEnabled =
false
;
49
# This two-factor extension isn't enabled by the user,
50
# but others may be.
51
return
true
;
52
}
53
}
54
}
getUser
getUser()
MediaWiki\Extension\OATHAuth\Hook\TwoFactorIsEnabled\SetIsEnabled
Definition
SetIsEnabled.php:9
MediaWiki\Extension\OATHAuth\Hook\TwoFactorIsEnabled\SetIsEnabled\callback
static callback(&$isEnabled)
Definition
SetIsEnabled.php:24
MediaWiki\Extension\OATHAuth\Hook\TwoFactorIsEnabled\SetIsEnabled\$isEnabled
bool $isEnabled
Definition
SetIsEnabled.php:18
MediaWiki\Extension\OATHAuth\Hook\TwoFactorIsEnabled\SetIsEnabled\__construct
__construct( $authUser, &$isEnabled)
SetIsEnabled constructor.
Definition
SetIsEnabled.php:36
MediaWiki\Extension\OATHAuth\Hook\TwoFactorIsEnabled\SetIsEnabled\$authUser
OATHUser $authUser
Definition
SetIsEnabled.php:13
MediaWiki\Extension\OATHAuth\Hook\TwoFactorIsEnabled\SetIsEnabled\execute
execute()
Definition
SetIsEnabled.php:41
MediaWiki\Extension\OATHAuth\OATHUser
Class representing a user from OATH's perspective.
Definition
OATHUser.php:28
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition
MediaWikiServices.php:117
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
Definition
MediaWikiServices.php:138
RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition
RequestContext.php:33
MediaWiki\Extension\OATHAuth\Hook\TwoFactorIsEnabled
Definition
SetIsEnabled.php:3
extensions
OATHAuth
src
Hook
TwoFactorIsEnabled
SetIsEnabled.php
Generated on Mon Nov 25 2024 16:04:39 for MediaWiki by
1.10.0