diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/OATHAuth/maintenance |
first commit
Diffstat (limited to 'www/wiki/extensions/OATHAuth/maintenance')
-rw-r--r-- | www/wiki/extensions/OATHAuth/maintenance/disableOATHAuthForUser.php | 40 | ||||
-rw-r--r-- | www/wiki/extensions/OATHAuth/maintenance/updateScratchTokenFormat.php | 51 |
2 files changed, 91 insertions, 0 deletions
diff --git a/www/wiki/extensions/OATHAuth/maintenance/disableOATHAuthForUser.php b/www/wiki/extensions/OATHAuth/maintenance/disableOATHAuthForUser.php new file mode 100644 index 00000000..612f07d7 --- /dev/null +++ b/www/wiki/extensions/OATHAuth/maintenance/disableOATHAuthForUser.php @@ -0,0 +1,40 @@ +<?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; diff --git a/www/wiki/extensions/OATHAuth/maintenance/updateScratchTokenFormat.php b/www/wiki/extensions/OATHAuth/maintenance/updateScratchTokenFormat.php new file mode 100644 index 00000000..81b4ea2d --- /dev/null +++ b/www/wiki/extensions/OATHAuth/maintenance/updateScratchTokenFormat.php @@ -0,0 +1,51 @@ +<?php +/** + * Update scratch_token column format + * + * Usage: php updateScratchTokenFormat.php + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * + * @file + * @author Darian Anthony Patrick + * @ingroup Maintenance + */ + +if ( getenv( 'MW_INSTALL_PATH' ) ) { + $IP = getenv( 'MW_INSTALL_PATH' ); +} else { + $IP = __DIR__ . '/../../..'; +} +require_once "$IP/maintenance/Maintenance.php"; + +class UpdateScratchTokenFormat extends Maintenance { + function __construct() { + parent::__construct(); + $this->mDescription = 'Script to update scratch_token column format'; + $this->requireExtension( 'OATHAuth' ); + } + + public function execute() { + $dbw = $this->getDB( DB_MASTER ); + if ( !OATHAuthHooks::schemaUpdateOldUsers( $dbw ) ) { + $this->error( "Failed to update scratch_token rows.\n", 1 ); + } + $this->output( "Done.\n" ); + } +} + +$maintClass = "UpdateScratchTokenFormat"; +require_once RUN_MAINTENANCE_IF_MAIN; |