Simplifying domain getting/setting
authorRyan Lane <rlane@wikimedia.org>
Thu, 21 Jun 2012 12:59:01 +0000 (14:59 +0200)
committerRyan Lane <rlane@wikimedia.org>
Thu, 21 Jun 2012 12:59:01 +0000 (14:59 +0200)
Adding a function to AuthPlugin for getting the user's domain. This allows the extension to determine how the user's domain is get and set, rather than core.

Change-Id: Ib2414bd55dfde67f7caf6439680fa88d9266e991

RELEASE-NOTES-1.20
includes/AuthPlugin.php
includes/specials/SpecialChangePassword.php
includes/specials/SpecialUserlogin.php

index addf484..21d63d9 100644 (file)
@@ -71,6 +71,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
 * cleanupSpam.php now can delete spam pages if --delete was specified instead of blanking
   them.
 * Added new hook ChangePasswordForm to allow adding of additional fields in Special:ChangePassword
+* Added new function getDomain to AuthPlugin for getting a user's domain
 
 === Bug fixes in 1.20 ===
 * (bug 30245) Use the correct way to construct a log page title.
index e550473..9cdd4f3 100644 (file)
@@ -83,6 +83,19 @@ class AuthPlugin {
                $this->domain = $domain;
        }
 
+       /**
+        * Get the user's domain
+        *
+        * @return string
+        */
+       public function getDomain() {
+               if ( $this->domain ) {
+                       return $this->domain;
+               } else {
+                       return 'invaliddomain';
+               }
+       }
+
        /**
         * Check to see if the specific domain is a valid domain.
         *
index 2b88325..b30605b 100644 (file)
@@ -63,10 +63,7 @@ class SpecialChangePassword extends UnlistedSpecialPage {
 
                if( $request->wasPosted() && $user->matchEditToken( $request->getVal( 'token' ) ) ) {
                        try {
-                               if ( isset( $_SESSION['wsDomain'] ) ) {
-                                       $this->mDomain = $_SESSION['wsDomain'];
-                               }
-                               $wgAuth->setDomain( $this->mDomain );
+                               $this->mDomain = $wgAuth->getDomain();
                                if( !$wgAuth->allowPasswordChange() ) {
                                        $this->error( $this->msg( 'resetpass_forbidden' )->text() );
                                        return;
index ded2721..7d91096 100644 (file)
@@ -125,11 +125,7 @@ class LoginForm extends SpecialPage {
                }
 
                if( !$wgAuth->validDomain( $this->mDomain ) ) {
-                       if ( isset( $_SESSION['wsDomain'] ) ) {
-                               $this->mDomain = $_SESSION['wsDomain'];
-                       } else {
-                               $this->mDomain = 'invaliddomain';
-                       }
+                       $this->mDomain = $wgAuth->getDomain();
                }
                $wgAuth->setDomain( $this->mDomain );