MediaWiki REL1_34
SetIsEnabled.php
Go to the documentation of this file.
1<?php
2
4
8
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()
__construct( $authUser, &$isEnabled)
SetIsEnabled constructor.
Class representing a user from OATH's perspective.
Definition OATHUser.php:28
MediaWikiServices is the service locator for the application scope of MediaWiki.
static getInstance()
Returns the global default instance of the top level service locator.
Group all the pieces relevant to the context of a request into one instance.