-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hook to ConfirmAccount to filter out requests
We recently upgraded our wiki and it is being spammed now with account requests that include a URL. We'd like to filter out those requests. Bug: T379300 Change-Id: I4fad0888a219810606d1654bbeb7d7573b218d54
- Loading branch information
Showing
8 changed files
with
133 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
indent_size = tab | ||
tab_width = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
# Ensure text editors don't turn leading spaces into tabs, | ||
# e.g. in multi-line bullet list items | ||
[*.md] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[.git/**] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (C) 2024 NicheWork, LLC | ||
* | ||
* 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 3 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, see <http://www.gnu.org/licenses/>. | ||
* | ||
* @author Mark A. Hershberger <[email protected]> | ||
*/ | ||
|
||
namespace MediaWiki\Extension\ConfirmAccount; | ||
|
||
use MediaWiki\User\User; | ||
|
||
// phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps | ||
interface ConfirmAccount__checkRequestHook { | ||
// phpcs:ignore MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName | ||
public function onConfirmAccount__checkRequest( | ||
User $user, | ||
array $params, | ||
string &$message | ||
): ?bool; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright (C) 2024 NicheWork, LLC | ||
* | ||
* 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 3 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, see <http://www.gnu.org/licenses/>. | ||
* | ||
* @author Mark A. Hershberger <[email protected]> | ||
*/ | ||
|
||
namespace MediaWiki\Extension\ConfirmAccount; | ||
|
||
use MediaWiki\HookContainer\HookContainer; | ||
use MediaWiki\User\User; | ||
|
||
class HookRunner implements ConfirmAccount__checkRequestHook { | ||
private HookContainer $container; | ||
|
||
public function __construct( HookContainer $container ) { | ||
$this->container = $container; | ||
} | ||
|
||
// phpcs:ignore MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName | ||
public function onConfirmAccount__checkRequest( | ||
User $user, | ||
array $params, | ||
string &$message | ||
): ?bool { | ||
return $this->container->run( | ||
'ConfirmAccount::checkRequest', | ||
[ $user, $params, &$message ] | ||
); | ||
} | ||
} |