From af0a9902bdd0ec4b8571af02d043c26fe6eef464 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Fri, 14 Apr 2006 21:56:11 +0000 Subject: [PATCH] Add $wgReservedUsernames configuration directive to block account creation/use --- RELEASE-NOTES | 1 + includes/DefaultSettings.php | 6 ++++++ includes/SpecialUserlogin.php | 9 ++++----- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 106c51862f..ad6275268b 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -71,6 +71,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * installer: show realpath when asking to chmod g+w ./config * installer: hide errors returned when trying to dl() mysql.so / pgsql.so * installer: cleanly outputbuffer when dieing out +* Add $wgReservedUsernames configuration directive to block account creation/use == Compatibility == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 9c22bd704c..f3b8e0ba89 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1936,4 +1936,10 @@ $wgAjaxExportList = array( 'wfSajaxSearch' ); */ $wgAllowDisplayTitle = false ; +/** + * Array of usernames which may not be registered or logged in from + * Maintenance scripts can still use these + */ +$wgReservedUsernames = array( 'MediaWiki default', 'Conversion script' ); + ?> diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 1f6e5a5951..f112acdd69 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -164,7 +164,7 @@ class LoginForm { global $wgUser, $wgOut; global $wgEnableSorbs, $wgProxyWhitelist; global $wgMemc, $wgAccountCreationThrottle, $wgDBname; - global $wgAuth, $wgMinimalPasswordLength; + global $wgAuth, $wgMinimalPasswordLength, $wgReservedUsernames; // If the user passes an invalid domain, something is fishy if( !$wgAuth->validDomain( $this->mDomain ) ) { @@ -205,7 +205,7 @@ class LoginForm { $name = trim( $this->mName ); $u = User::newFromName( $name ); - if ( is_null( $u ) || $u->getName() == 'MediaWiki default' ) { + if ( is_null( $u ) || in_array( $u->getName(), $wgReservedUsernames ) ) { $this->mainLoginForm( wfMsg( 'noname' ) ); return false; } @@ -284,15 +284,14 @@ class LoginForm { * @access private */ function processLogin() { - global $wgUser; - global $wgAuth; + global $wgUser, $wgAuth, $wgReservedUsernames; if ( '' == $this->mName ) { $this->mainLoginForm( wfMsg( 'noname' ) ); return; } $u = User::newFromName( $this->mName ); - if( is_null( $u ) || $u->getName() == 'MediaWiki default' ) { + if( is_null( $u ) || in_array( $u->getName(), $wgReservedUsernames ) ) { $this->mainLoginForm( wfMsg( 'noname' ) ); return; } -- 2.20.1