From: Ryan Lane Date: Fri, 9 Mar 2007 19:31:52 +0000 (+0000) Subject: Adding setInternalPassword(), and changing the behavior of setPassword in User.php. X-Git-Tag: 1.31.0-rc.0~53825 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=32b36bf7dcee19340c7a99869e74a0c26e88d1d9;p=lhc%2Fweb%2Fwiklou.git Adding setInternalPassword(), and changing the behavior of setPassword in User.php. Adding a check into SpecialUserLogin's initUser() function to only set a password if authentication plugins allow it. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 33f896ab0c..0432bbdfe8 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -261,7 +261,7 @@ lighter making things easier to read. * Link from Special:log/protect to change protection form * Fix fallback implementation of mb_strlen so it works and isn't insanely slow for large strings, since it's used for page edit lengths - +* (bug 8815) Setting password in initUser() breaks LdapAuthentication plugin == Languages updated == diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 3787c5e529..a34558f0f8 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -301,13 +301,18 @@ class LoginForm { * @private */ function initUser( $u ) { + global $wgAuth; + $u->addToDatabase(); - $u->setPassword( $this->mPassword ); + + if ( $wgAuth->allowPasswordChange() ) { + $u->setPassword( $this->mPassword ); + } + $u->setEmail( $this->mEmail ); $u->setRealName( $this->mRealName ); $u->setToken(); - global $wgAuth; $wgAuth->initUser( $u ); $u->setOption( 'rememberpassword', $this->mRemember ? 1 : 0 ); diff --git a/includes/User.php b/includes/User.php index 119dbf2956..c285bc8f5a 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1394,11 +1394,23 @@ class User { $wgMinimalPasswordLength ) ); } } - + if( !$wgAuth->setPassword( $this, $str ) ) { throw new PasswordError( wfMsg( 'externaldberror' ) ); } + $this->setInternalPassword( $str ); + + return true; + } + + /** + * Set the password and reset the random token no matter + * what. + * + * @param string $str + */ + function setInternalPassword( $str ) { $this->load(); $this->setToken(); @@ -1410,10 +1422,7 @@ class User { } $this->mNewpassword = ''; $this->mNewpassTime = null; - - return true; } - /** * Set the random token (used for persistent authentication) * Called from loadDefaults() among other places.