Page MenuHomePhabricator

wgBlockDisablesLogin-tim1.patch

Authored By
bzimport
Nov 21 2014, 11:35 PM
Size
2 KB
Referenced Files
None
Subscribers
None

wgBlockDisablesLogin-tim1.patch

Index: includes/User.php
===================================================================
--- includes/User.php (revision 87235)
+++ includes/User.php (working copy)
@@ -937,24 +937,25 @@
return false;
}
- $this->mId = $sId;
- if ( !$this->loadFromId() ) {
- # Not a valid ID, loadFromId has switched the object to anon for us
+ $proposedUser = User::newFromId( $sId );
+ if ( !$proposedUser->isLoggedIn() ) {
+ # Not a valid ID
+ $this->loadDefaults();
return false;
}
global $wgBlockDisablesLogin;
- if( $wgBlockDisablesLogin && $this->isBlocked() ) {
+ if( $wgBlockDisablesLogin && $proposedUser->isBlocked() ) {
# User blocked and we've disabled blocked user logins
$this->loadDefaults();
return false;
}
if ( $wgRequest->getSessionData( 'wsToken' ) !== null ) {
- $passwordCorrect = $this->mToken == $wgRequest->getSessionData( 'wsToken' );
+ $passwordCorrect = $proposedUser->getToken() == $wgRequest->getSessionData( 'wsToken' );
$from = 'session';
} else if ( $wgRequest->getCookie( 'Token' ) !== null ) {
- $passwordCorrect = $this->mToken == $wgRequest->getCookie( 'Token' );
+ $passwordCorrect = $proposedUser->getToken() == $wgRequest->getCookie( 'Token' );
$from = 'cookie';
} else {
# No session or persistent login cookie
@@ -962,7 +963,8 @@
return false;
}
- if ( ( $sName == $this->mName ) && $passwordCorrect ) {
+ if ( ( $sName === $proposedUser->getName() ) && $passwordCorrect ) {
+ $this->loadFromUserObject( $proposedUser );
$wgRequest->setSessionData( 'wsToken', $this->mToken );
wfDebug( "User: logged in from $from\n" );
return true;
@@ -1064,6 +1066,18 @@
}
/**
+ * Load the data for this user object from another user object.
+ */
+ protected function loadFromUserObject( $user ) {
+ $user->load();
+ $user->loadGroups();
+ $user->loadOptions();
+ foreach ( self::$mCacheVars as $var ) {
+ $this->$var = $user->$var;
+ }
+ }
+
+ /**
* Load the groups from the database if they aren't already loaded.
* @private
*/

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
7387
Default Alt Text
wgBlockDisablesLogin-tim1.patch (2 KB)

Event Timeline