Index: trunk/phase3/includes/specials/SpecialUserlogin.php |
— | — | @@ -43,54 +43,54 @@ |
44 | 44 | const NEED_TOKEN = 12; |
45 | 45 | const WRONG_TOKEN = 13; |
46 | 46 | |
47 | | - var $mName, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted; |
| 47 | + var $mUsername, $mPassword, $mRetype, $mReturnTo, $mCookieCheck, $mPosted; |
48 | 48 | var $mAction, $mCreateaccount, $mCreateaccountMail, $mMailmypassword; |
49 | 49 | var $mLoginattempt, $mRemember, $mEmail, $mDomain, $mLanguage; |
50 | | - var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS, $mRequest; |
| 50 | + var $mSkipCookieCheck, $mReturnToQuery, $mToken, $mStickHTTPS; |
51 | 51 | |
52 | 52 | private $mExtUser = null; |
53 | 53 | |
54 | 54 | public function __construct( $request = null ) { |
| 55 | + parent::__construct( 'Userlogin' ); |
| 56 | + |
55 | 57 | if ( $request === null ) { |
56 | 58 | global $wgRequest; |
57 | | - $this->mRequest = $wgRequest; |
| 59 | + $this->load( $wgRequest ); |
58 | 60 | } else { |
59 | | - $this->mRequest = $request; |
| 61 | + $this->load( $request ); |
60 | 62 | } |
61 | | - |
62 | | - parent::__construct( 'Userlogin' ); |
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | 66 | * Loader |
67 | 67 | * |
68 | | - * @param $par String: subpage parameter |
| 68 | + * @param $request WebRequest object |
69 | 69 | */ |
70 | | - function load( $par ) { |
| 70 | + function load( $request ) { |
71 | 71 | global $wgAuth, $wgHiddenPrefs, $wgEnableEmail, $wgRedirectOnLogin; |
72 | 72 | |
73 | | - $this->mType = ( $par == 'signup' ) ? $par : $this->mRequest->getText( 'type' ); # Check for [[Special:Userlogin/signup]] |
74 | | - $this->mName = $this->mRequest->getText( 'wpName' ); |
75 | | - $this->mPassword = $this->mRequest->getText( 'wpPassword' ); |
76 | | - $this->mRetype = $this->mRequest->getText( 'wpRetype' ); |
77 | | - $this->mDomain = $this->mRequest->getText( 'wpDomain' ); |
78 | | - $this->mReason = $this->mRequest->getText( 'wpReason' ); |
79 | | - $this->mReturnTo = $this->mRequest->getVal( 'returnto' ); |
80 | | - $this->mReturnToQuery = $this->mRequest->getVal( 'returntoquery' ); |
81 | | - $this->mCookieCheck = $this->mRequest->getVal( 'wpCookieCheck' ); |
82 | | - $this->mPosted = $this->mRequest->wasPosted(); |
83 | | - $this->mCreateaccount = $this->mRequest->getCheck( 'wpCreateaccount' ); |
84 | | - $this->mCreateaccountMail = $this->mRequest->getCheck( 'wpCreateaccountMail' ) |
| 73 | + $this->mType = $request->getText( 'type' ); |
| 74 | + $this->mUsername = $request->getText( 'wpName' ); |
| 75 | + $this->mPassword = $request->getText( 'wpPassword' ); |
| 76 | + $this->mRetype = $request->getText( 'wpRetype' ); |
| 77 | + $this->mDomain = $request->getText( 'wpDomain' ); |
| 78 | + $this->mReason = $request->getText( 'wpReason' ); |
| 79 | + $this->mReturnTo = $request->getVal( 'returnto' ); |
| 80 | + $this->mReturnToQuery = $request->getVal( 'returntoquery' ); |
| 81 | + $this->mCookieCheck = $request->getVal( 'wpCookieCheck' ); |
| 82 | + $this->mPosted = $request->wasPosted(); |
| 83 | + $this->mCreateaccount = $request->getCheck( 'wpCreateaccount' ); |
| 84 | + $this->mCreateaccountMail = $request->getCheck( 'wpCreateaccountMail' ) |
85 | 85 | && $wgEnableEmail; |
86 | | - $this->mMailmypassword = $this->mRequest->getCheck( 'wpMailmypassword' ) |
| 86 | + $this->mMailmypassword = $request->getCheck( 'wpMailmypassword' ) |
87 | 87 | && $wgEnableEmail; |
88 | | - $this->mLoginattempt = $this->mRequest->getCheck( 'wpLoginattempt' ); |
89 | | - $this->mAction = $this->mRequest->getVal( 'action' ); |
90 | | - $this->mRemember = $this->mRequest->getCheck( 'wpRemember' ); |
91 | | - $this->mStickHTTPS = $this->mRequest->getCheck( 'wpStickHTTPS' ); |
92 | | - $this->mLanguage = $this->mRequest->getText( 'uselang' ); |
93 | | - $this->mSkipCookieCheck = $this->mRequest->getCheck( 'wpSkipCookieCheck' ); |
94 | | - $this->mToken = ( $this->mType == 'signup' ) ? $this->mRequest->getVal( 'wpCreateaccountToken' ) : $this->mRequest->getVal( 'wpLoginToken' ); |
| 88 | + $this->mLoginattempt = $request->getCheck( 'wpLoginattempt' ); |
| 89 | + $this->mAction = $request->getVal( 'action' ); |
| 90 | + $this->mRemember = $request->getCheck( 'wpRemember' ); |
| 91 | + $this->mStickHTTPS = $request->getCheck( 'wpStickHTTPS' ); |
| 92 | + $this->mLanguage = $request->getText( 'uselang' ); |
| 93 | + $this->mSkipCookieCheck = $request->getCheck( 'wpSkipCookieCheck' ); |
| 94 | + $this->mToken = ( $this->mType == 'signup' ) ? $request->getVal( 'wpCreateaccountToken' ) : $request->getVal( 'wpLoginToken' ); |
95 | 95 | |
96 | 96 | if ( $wgRedirectOnLogin ) { |
97 | 97 | $this->mReturnTo = $wgRedirectOnLogin; |
— | — | @@ -98,12 +98,12 @@ |
99 | 99 | } |
100 | 100 | |
101 | 101 | if( $wgEnableEmail ) { |
102 | | - $this->mEmail = $this->mRequest->getText( 'wpEmail' ); |
| 102 | + $this->mEmail = $request->getText( 'wpEmail' ); |
103 | 103 | } else { |
104 | 104 | $this->mEmail = ''; |
105 | 105 | } |
106 | 106 | if( !in_array( 'realname', $wgHiddenPrefs ) ) { |
107 | | - $this->mRealName = $this->mRequest->getText( 'wpRealName' ); |
| 107 | + $this->mRealName = $request->getText( 'wpRealName' ); |
108 | 108 | } else { |
109 | 109 | $this->mRealName = ''; |
110 | 110 | } |
— | — | @@ -126,7 +126,9 @@ |
127 | 127 | wfSetupSession(); |
128 | 128 | } |
129 | 129 | |
130 | | - $this->load( $par ); |
| 130 | + if ( $par == 'signup' ) { # Check for [[Special:Userlogin/signup]] |
| 131 | + $this->mType = 'signup'; |
| 132 | + } |
131 | 133 | |
132 | 134 | if ( !is_null( $this->mCookieCheck ) ) { |
133 | 135 | $this->onCookieRedirectCheck( $this->mCookieCheck ); |
— | — | @@ -152,7 +154,7 @@ |
153 | 155 | global $wgOut; |
154 | 156 | |
155 | 157 | if ( $this->mEmail == '' ) { |
156 | | - $this->mainLoginForm( wfMsgExt( 'noemail', array( 'parsemag', 'escape' ), $this->mName ) ); |
| 158 | + $this->mainLoginForm( wfMsgExt( 'noemail', array( 'parsemag', 'escape' ), $this->mUsername ) ); |
157 | 159 | return; |
158 | 160 | } |
159 | 161 | |
— | — | @@ -258,7 +260,7 @@ |
259 | 261 | // create a local account and login as any domain user). We only need |
260 | 262 | // to check this for domains that aren't local. |
261 | 263 | if( 'local' != $this->mDomain && $this->mDomain != '' ) { |
262 | | - if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mName ) || !$wgAuth->authenticate( $this->mName, $this->mPassword ) ) ) { |
| 264 | + if( !$wgAuth->canCreateAccounts() && ( !$wgAuth->userExists( $this->mUsername ) || !$wgAuth->authenticate( $this->mUsername, $this->mPassword ) ) ) { |
263 | 265 | $this->mainLoginForm( wfMsg( 'wrongpassword' ) ); |
264 | 266 | return false; |
265 | 267 | } |
— | — | @@ -304,7 +306,7 @@ |
305 | 307 | } |
306 | 308 | |
307 | 309 | # Now create a dummy user ($u) and check if it is valid |
308 | | - $name = trim( $this->mName ); |
| 310 | + $name = trim( $this->mUsername ); |
309 | 311 | $u = User::newFromName( $name, 'creatable' ); |
310 | 312 | if ( !is_object( $u ) ) { |
311 | 313 | $this->mainLoginForm( wfMsg( 'noname' ) ); |
— | — | @@ -433,7 +435,7 @@ |
434 | 436 | public function authenticateUserData() { |
435 | 437 | global $wgUser, $wgAuth, $wgMemc; |
436 | 438 | |
437 | | - if ( $this->mName == '' ) { |
| 439 | + if ( $this->mUsername == '' ) { |
438 | 440 | return self::NO_NAME; |
439 | 441 | } |
440 | 442 | |
— | — | @@ -456,7 +458,7 @@ |
457 | 459 | |
458 | 460 | $throttleCount = 0; |
459 | 461 | if ( is_array( $wgPasswordAttemptThrottle ) ) { |
460 | | - $throttleKey = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mName ) ); |
| 462 | + $throttleKey = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mUsername ) ); |
461 | 463 | $count = $wgPasswordAttemptThrottle['count']; |
462 | 464 | $period = $wgPasswordAttemptThrottle['seconds']; |
463 | 465 | |
— | — | @@ -481,16 +483,16 @@ |
482 | 484 | // creates the user in the database. Until we load $wgUser, checking |
483 | 485 | // for user existence using User::newFromName($name)->getId() below |
484 | 486 | // will effectively be using stale data. |
485 | | - if ( $wgUser->getName() === $this->mName ) { |
486 | | - wfDebug( __METHOD__ . ": already logged in as {$this->mName}\n" ); |
| 487 | + if ( $wgUser->getName() === $this->mUsername ) { |
| 488 | + wfDebug( __METHOD__ . ": already logged in as {$this->mUsername}\n" ); |
487 | 489 | return self::SUCCESS; |
488 | 490 | } |
489 | 491 | |
490 | | - $this->mExtUser = ExternalUser::newFromName( $this->mName ); |
| 492 | + $this->mExtUser = ExternalUser::newFromName( $this->mUsername ); |
491 | 493 | |
492 | 494 | # TODO: Allow some magic here for invalid external names, e.g., let the |
493 | 495 | # user choose a different wiki name. |
494 | | - $u = User::newFromName( $this->mName ); |
| 496 | + $u = User::newFromName( $this->mUsername ); |
495 | 497 | if( !( $u instanceof User ) || !User::isUsableName( $u->getName() ) ) { |
496 | 498 | return self::ILLEGAL; |
497 | 499 | } |
— | — | @@ -639,7 +641,7 @@ |
640 | 642 | self::clearLoginToken(); |
641 | 643 | |
642 | 644 | // Reset the throttle |
643 | | - $key = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mName ) ); |
| 645 | + $key = wfMemcKey( 'password-throttle', wfGetIP(), md5( $this->mUsername ) ); |
644 | 646 | global $wgMemc; |
645 | 647 | $wgMemc->delete( $key ); |
646 | 648 | |
— | — | @@ -671,9 +673,9 @@ |
672 | 674 | break; |
673 | 675 | case self::NOT_EXISTS: |
674 | 676 | if( $wgUser->isAllowed( 'createaccount' ) ) { |
675 | | - $this->mainLoginForm( wfMsgWikiHtml( 'nosuchuser', htmlspecialchars( $this->mName ) ) ); |
| 677 | + $this->mainLoginForm( wfMsgWikiHtml( 'nosuchuser', htmlspecialchars( $this->mUsername ) ) ); |
676 | 678 | } else { |
677 | | - $this->mainLoginForm( wfMsg( 'nosuchusershort', htmlspecialchars( $this->mName ) ) ); |
| 679 | + $this->mainLoginForm( wfMsg( 'nosuchusershort', htmlspecialchars( $this->mUsername ) ) ); |
678 | 680 | } |
679 | 681 | break; |
680 | 682 | case self::WRONG_PASS: |
— | — | @@ -693,7 +695,7 @@ |
694 | 696 | break; |
695 | 697 | case self::USER_BLOCKED: |
696 | 698 | $this->mainLoginForm( wfMsgExt( 'login-userblocked', |
697 | | - array( 'parsemag', 'escape' ), $this->mName ) ); |
| 699 | + array( 'parsemag', 'escape' ), $this->mUsername ) ); |
698 | 700 | break; |
699 | 701 | default: |
700 | 702 | throw new MWException( 'Unhandled case value' ); |
— | — | @@ -732,7 +734,7 @@ |
733 | 735 | |
734 | 736 | # Check for hooks |
735 | 737 | $error = null; |
736 | | - if ( !wfRunHooks( 'UserLoginMailPassword', array( $this->mName, &$error ) ) ) { |
| 738 | + if ( !wfRunHooks( 'UserLoginMailPassword', array( $this->mUsername, &$error ) ) ) { |
737 | 739 | $this->mainLoginForm( $error ); |
738 | 740 | return; |
739 | 741 | } |
— | — | @@ -756,11 +758,11 @@ |
757 | 759 | return; |
758 | 760 | } |
759 | 761 | |
760 | | - if ( $this->mName == '' ) { |
| 762 | + if ( $this->mUsername == '' ) { |
761 | 763 | $this->mainLoginForm( wfMsg( 'noname' ) ); |
762 | 764 | return; |
763 | 765 | } |
764 | | - $u = User::newFromName( $this->mName ); |
| 766 | + $u = User::newFromName( $this->mUsername ); |
765 | 767 | if( !$u instanceof User ) { |
766 | 768 | $this->mainLoginForm( wfMsg( 'noname' ) ); |
767 | 769 | return; |
— | — | @@ -946,11 +948,11 @@ |
947 | 949 | } |
948 | 950 | } |
949 | 951 | |
950 | | - if ( $this->mName == '' ) { |
| 952 | + if ( $this->mUsername == '' ) { |
951 | 953 | if ( $wgUser->isLoggedIn() ) { |
952 | | - $this->mName = $wgUser->getName(); |
| 954 | + $this->mUsername = $wgUser->getName(); |
953 | 955 | } else { |
954 | | - $this->mName = $wgRequest->getCookie( 'UserName' ); |
| 956 | + $this->mUsername = $wgRequest->getCookie( 'UserName' ); |
955 | 957 | } |
956 | 958 | } |
957 | 959 | |
— | — | @@ -997,7 +999,7 @@ |
998 | 1000 | } |
999 | 1001 | |
1000 | 1002 | $template->set( 'header', '' ); |
1001 | | - $template->set( 'name', $this->mName ); |
| 1003 | + $template->set( 'name', $this->mUsername ); |
1002 | 1004 | $template->set( 'password', $this->mPassword ); |
1003 | 1005 | $template->set( 'retype', $this->mRetype ); |
1004 | 1006 | $template->set( 'email', $this->mEmail ); |