mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/OATHAuth
synced 2024-11-28 10:10:19 +00:00
c02f2f13b5
The following sniffs are failing and were disabled: * MediaWiki.Commenting.FunctionComment.MissingParamComment * MediaWiki.Commenting.FunctionComment.MissingParamTag * MediaWiki.Commenting.FunctionComment.MissingReturn * MediaWiki.Commenting.FunctionComment.ParamNameNoMatch * MediaWiki.FunctionComment.Missing.Protected * MediaWiki.FunctionComment.Missing.Public Change-Id: I79250c955f70faf177ada5c7328576abed88011c
41 lines
1 KiB
PHP
41 lines
1 KiB
PHP
<?php
|
|
|
|
if ( getenv( 'MW_INSTALL_PATH' ) ) {
|
|
$IP = getenv( 'MW_INSTALL_PATH' );
|
|
} else {
|
|
$IP = __DIR__ . '/../../..';
|
|
}
|
|
require_once "$IP/maintenance/Maintenance.php";
|
|
|
|
class DisableOATHAuthForUser extends Maintenance {
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->mDescription = 'Remove OATHAuth from a specific user';
|
|
$this->addArg( 'user', 'The username to remove OATHAuth from.' );
|
|
$this->requireExtension( 'OATHAuth' );
|
|
}
|
|
|
|
public function execute() {
|
|
$username = $this->getArg( 0 );
|
|
|
|
$user = User::newFromName( $username );
|
|
if ( $user && $user->getId() === 0 ) {
|
|
$this->error( "User $username doesn't exist!", 1 );
|
|
}
|
|
|
|
$repo = OATHAuthHooks::getOATHUserRepository();
|
|
|
|
$oathUser = $repo->findByUser( $user );
|
|
|
|
if ( $oathUser->getKey() === null ) {
|
|
$this->error( "User $username doesn't have OATHAuth enabled!", 1 );
|
|
}
|
|
|
|
$repo->remove( $oathUser );
|
|
$this->output( "OATHAuth disabled for $username.\n" );
|
|
}
|
|
}
|
|
|
|
$maintClass = "DisableOATHAuthForUser";
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|