MediaWiki  1.32.0
disableOATHAuthForUser.php
Go to the documentation of this file.
1 <?php
2 
3 if ( getenv( 'MW_INSTALL_PATH' ) ) {
4  $IP = getenv( 'MW_INSTALL_PATH' );
5 } else {
6  $IP = __DIR__ . '/../../..';
7 }
8 require_once "$IP/maintenance/Maintenance.php";
9 
11  function __construct() {
12  parent::__construct();
13  $this->mDescription = 'Remove OATHAuth from a specific user';
14  $this->addArg( 'user', 'The username to remove OATHAuth from.' );
15  $this->requireExtension( 'OATHAuth' );
16  }
17 
18  public function execute() {
19  $username = $this->getArg( 0 );
20 
22  if ( $user && $user->getId() === 0 ) {
23  $this->error( "User $username doesn't exist!", 1 );
24  }
25 
27 
28  $oathUser = $repo->findByUser( $user );
29 
30  if ( $oathUser->getKey() === null ) {
31  $this->error( "User $username doesn't have OATHAuth enabled!", 1 );
32  }
33 
34  $repo->remove( $oathUser );
35  $this->output( "OATHAuth disabled for $username.\n" );
36  }
37 }
38 
39 $maintClass = "DisableOATHAuthForUser";
40 require_once RUN_MAINTENANCE_IF_MAIN;
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:244
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:592
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
$maintClass
$maintClass
Definition: disableOATHAuthForUser.php:39
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
DisableOATHAuthForUser\execute
execute()
Do the actual work.
Definition: disableOATHAuthForUser.php:18
DisableOATHAuthForUser
Definition: disableOATHAuthForUser.php:10
$IP
$IP
Definition: update.php:3
Maintenance\requireExtension
requireExtension( $name)
Indicate that the specified extension must be loaded before the script can run.
Definition: Maintenance.php:599
DisableOATHAuthForUser\__construct
__construct()
Default constructor.
Definition: disableOATHAuthForUser.php:11
Maintenance\addArg
addArg( $arg, $description, $required=true)
Add some args that are needed.
Definition: Maintenance.php:288
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:442
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:414
OATHAuthHooks\getOATHUserRepository
static getOATHUserRepository()
Get the singleton OATH user repository.
Definition: OATHAuthHooks.php:34
Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition: Maintenance.php:336
$username
this hook is for auditing only or null if authentication failed before getting that far $username
Definition: hooks.txt:813