X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialChangePassword.php;h=df68b12c3c43f9849a1f12dadfbde5e608787714;hb=ff9f2fa33719753ff0c708f9b4a84c57593b9e58;hp=24664edb7c4bfa64bb3eb01bed68c07e3cbaea6a;hpb=0c615d9029cb6e0d65c21f1df5a8a54e197b860a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialChangePassword.php b/includes/specials/SpecialChangePassword.php index 24664edb7c..df68b12c3c 100644 --- a/includes/specials/SpecialChangePassword.php +++ b/includes/specials/SpecialChangePassword.php @@ -118,7 +118,7 @@ class SpecialChangePassword extends FormSpecialPage { } $extraFields = array(); - wfRunHooks( 'ChangePasswordForm', array( &$extraFields ) ); + Hooks::run( 'ChangePasswordForm', array( &$extraFields ) ); foreach ( $extraFields as $extra ) { list( $name, $label, $type, $default ) = $extra; $fields[$name] = array( @@ -179,7 +179,8 @@ class SpecialChangePassword extends FormSpecialPage { } if ( $request->getCheck( 'wpCancel' ) ) { - $titleObj = Title::newFromText( $request->getVal( 'returnto' ) ); + $returnto = $request->getVal( 'returnto' ); + $titleObj = $returnto !== null ? Title::newFromText( $returnto ) : null; if ( !$titleObj instanceof Title ) { $titleObj = Title::newMainPage(); } @@ -248,7 +249,7 @@ class SpecialChangePassword extends FormSpecialPage { } if ( $newpass !== $retype ) { - wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'badretype' ) ); + Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'badretype' ) ); throw new PasswordError( $this->msg( 'badretype' )->text() ); } @@ -264,7 +265,7 @@ class SpecialChangePassword extends FormSpecialPage { // @todo Make these separate messages, since the message is written for both cases if ( !$user->checkTemporaryPassword( $oldpass ) && !$user->checkPassword( $oldpass ) ) { - wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'wrongpassword' ) ); + Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'wrongpassword' ) ); throw new PasswordError( $this->msg( 'resetpass-wrong-oldpass' )->text() ); } @@ -276,8 +277,8 @@ class SpecialChangePassword extends FormSpecialPage { // Do AbortChangePassword after checking mOldpass, so we don't leak information // by possibly aborting a new password before verifying the old password. $abortMsg = 'resetpass-abort-generic'; - if ( !wfRunHooks( 'AbortChangePassword', array( $user, $oldpass, $newpass, &$abortMsg ) ) ) { - wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'abortreset' ) ); + if ( !Hooks::run( 'AbortChangePassword', array( $user, $oldpass, $newpass, &$abortMsg ) ) ) { + Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'abortreset' ) ); throw new PasswordError( $this->msg( $abortMsg )->text() ); } @@ -288,9 +289,9 @@ class SpecialChangePassword extends FormSpecialPage { try { $user->setPassword( $newpass ); - wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'success' ) ); + Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'success' ) ); } catch ( PasswordError $e ) { - wfRunHooks( 'PrefsPasswordAudit', array( $user, $newpass, 'error' ) ); + Hooks::run( 'PrefsPasswordAudit', array( $user, $newpass, 'error' ) ); throw new PasswordError( $e->getMessage() ); } @@ -300,8 +301,8 @@ class SpecialChangePassword extends FormSpecialPage { $remember = $this->getRequest()->getCookie( 'Token' ) !== null; $user->setCookies( null, null, $remember ); } - $user->resetPasswordExpiration(); $user->saveSettings(); + $this->resetPasswordExpiration( $user ); } public function requiresUnblock() { @@ -311,4 +312,28 @@ class SpecialChangePassword extends FormSpecialPage { protected function getGroupName() { return 'users'; } + + /** + * For resetting user password expiration, until AuthManager comes along + * @param User $user + */ + private function resetPasswordExpiration( User $user ) { + global $wgPasswordExpirationDays; + $newExpire = null; + if ( $wgPasswordExpirationDays ) { + $newExpire = wfTimestamp( + TS_MW, + time() + ( $wgPasswordExpirationDays * 24 * 3600 ) + ); + } + // Give extensions a chance to force an expiration + Hooks::run( 'ResetPasswordExpiration', array( $this, &$newExpire ) ); + $dbw = wfGetDB( DB_MASTER ); + $dbw->update( + 'user', + array( 'user_password_expires' => $dbw->timestampOrNull( $newExpire ) ), + array( 'user_id' => $user->getID() ), + __METHOD__ + ); + } }