From 5bf7522c8e8cf43234142f8858e347fa2d18fe1b Mon Sep 17 00:00:00 2001 From: Ryan Lane Date: Thu, 8 Sep 2011 19:54:32 +0000 Subject: [PATCH] Adding support for domains in SpecialPasswordReset.php. --- includes/AuthPlugin.php | 9 +++++++++ includes/specials/SpecialPasswordReset.php | 23 +++++++++++++++++++++- languages/messages/MessagesEn.php | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/includes/AuthPlugin.php b/includes/AuthPlugin.php index fd0624abad..2fdba79718 100644 --- a/includes/AuthPlugin.php +++ b/includes/AuthPlugin.php @@ -262,6 +262,15 @@ class AuthPlugin { public function getUserInstance( User &$user ) { return new AuthPluginUser( $user ); } + + /** + * Get a list of domains (in HTMLForm options format) used. + * + * @return array + */ + public function domainList() { + return array(); + } } class AuthPluginUser { diff --git a/includes/specials/SpecialPasswordReset.php b/includes/specials/SpecialPasswordReset.php index 5cdb1c04d1..b7aabc07a8 100644 --- a/includes/specials/SpecialPasswordReset.php +++ b/includes/specials/SpecialPasswordReset.php @@ -44,7 +44,7 @@ class SpecialPasswordReset extends FormSpecialPage { } protected function getFormFields() { - global $wgPasswordResetRoutes; + global $wgPasswordResetRoutes, $wgAuth; $a = array(); if ( isset( $wgPasswordResetRoutes['username'] ) && $wgPasswordResetRoutes['username'] ) { $a['Username'] = array( @@ -60,6 +60,15 @@ class SpecialPasswordReset extends FormSpecialPage { ); } + if ( isset( $wgPasswordResetRoutes['domain'] ) && $wgPasswordResetRoutes['domain'] ) { + $domains = $wgAuth->domainList(); + $a['Domain'] = array( + 'type' => 'select', + 'options' => $domains, + 'label-message' => 'passwordreset-domain', + ); + } + return $a; } @@ -76,6 +85,9 @@ class SpecialPasswordReset extends FormSpecialPage { if ( isset( $wgPasswordResetRoutes['email'] ) && $wgPasswordResetRoutes['email'] ) { $i++; } + if ( isset( $wgPasswordResetRoutes['domain'] ) && $wgPasswordResetRoutes['domain'] ) { + $i++; + } return wfMessage( 'passwordreset-pretext', $i )->parseAsBlock(); } @@ -87,6 +99,15 @@ class SpecialPasswordReset extends FormSpecialPage { * @return Bool|Array */ public function onSubmit( array $data ) { + global $wgAuth; + + if ( isset( $data['Domain'] ) ) { + if ( $wgAuth->validDomain( $data['Domain'] ) ) { + $wgAuth->setDomain( $data['Domain'] ); + } else { + $wgAuth->setDomain( 'invaliddomain' ); + } + } if ( isset( $data['Username'] ) && $data['Username'] !== '' ) { $method = 'username'; diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 4912d399c4..3460e4bee4 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1180,6 +1180,7 @@ You may have already successfully changed your password or requested a new tempo 'passwordreset-disabled' => 'Password resets have been disabled on this wiki.', 'passwordreset-pretext' => '{{PLURAL:$1||Enter one of the pieces of data below}}', 'passwordreset-username' => 'Username:', +'passwordreset-domain' => 'Domain:', 'passwordreset-email' => 'E-mail address:', 'passwordreset-emailtitle' => 'Account details on {{SITENAME}}', 'passwordreset-emailtext-ip' => 'Someone (probably you, from IP address $1) requested a reminder of your -- 2.20.1