Page MenuHomeWickedGov Phorge

Hooks.php
No OneTemporary

Size
2 KB
Referenced Files
None
Subscribers
None

Hooks.php

<?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
*/
namespace MediaWiki\Extension\AntiSpoof;
use MediaWiki\Auth\Hook\LocalUserCreatedHook;
use MediaWiki\Permissions\GrantsInfo;
use MediaWiki\RenameUser\Hook\RenameUserCompleteHook;
use MediaWiki\User\User;
class Hooks implements
LocalUserCreatedHook,
RenameUserCompleteHook
{
public static function onRegistration() {
global $wgGrantRiskGroups;
// Make sure the risk rating is at least 'security'. AntiSpoof adds the
// override-antispoof right to the createaccount grant, which makes it possible
// to use it for social engineering attacks with lookalike usernames.
if ( $wgGrantRiskGroups['createaccount'] !== GrantsInfo::RISK_INTERNAL ) {
$wgGrantRiskGroups['createaccount'] = GrantsInfo::RISK_SECURITY;
}
}
/**
* On new account creation, record the username's thing-bob.
* Replaces AddNewAccountHook for more modern MediaWiki versions-
*
* @param User $user
* @param bool $autocreated
*/
public function onLocalUserCreated( $user, $autocreated ) {
if ( !$user->isTemp() ) {
$spoof = new SpoofUser( $user->getName() );
$spoof->record();
}
}
/**
* On rename, remove the old entry and add the new
* (After a successful user rename)
*
* @param int $uid
* @param string $oldName
* @param string $newName
*/
public function onRenameUserComplete( int $uid, string $oldName, string $newName ): void {
$spoof = new SpoofUser( $newName );
$spoof->update( $oldName );
}
}

File Metadata

Mime Type
text/x-php
Expires
Aug 19 2026, 18:45 (6 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
56/dc/c78c6445caf9320f28a8a2ad7f4a
Default Alt Text
Hooks.php (2 KB)

Event Timeline