X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialChangeEmail.php;h=956ff77e8c1f2c9a07bbda655393bb093351f6fa;hp=4f97ba21762f62ff5ee3f40a02d4a42e24e1f57b;hb=616525021b3691e30a980a42b837b7ad44ecfd09;hpb=03608896716851972cc22d28d432d233be10edba diff --git a/includes/specials/SpecialChangeEmail.php b/includes/specials/SpecialChangeEmail.php index 4f97ba2176..956ff77e8c 100644 --- a/includes/specials/SpecialChangeEmail.php +++ b/includes/specials/SpecialChangeEmail.php @@ -22,6 +22,7 @@ */ use MediaWiki\Auth\AuthManager; +use MediaWiki\Logger\LoggerFactory; /** * Let users change their email address. @@ -54,14 +55,16 @@ class SpecialChangeEmail extends FormSpecialPage { * @param string $par */ function execute( $par ) { - $this->checkLoginSecurityLevel(); - $out = $this->getOutput(); $out->disallowUserJs(); parent::execute( $par ); } + protected function getLoginSecurityLevel() { + return $this->getName(); + } + protected function checkExecutePermissions( User $user ) { if ( !AuthManager::singleton()->allowsPropertyChange( 'emailaddress' ) ) { throw new ErrorPageError( 'changeemail', 'cannotchangeemail' ); @@ -75,6 +78,10 @@ class SpecialChangeEmail extends FormSpecialPage { throw new PermissionsError( 'viewmyprivateinfo' ); } + if ( $user->isBlockedFromEmailuser() ) { + throw new UserBlockedError( $user->getBlock() ); + } + parent::checkExecutePermissions( $user ); } @@ -159,16 +166,29 @@ class SpecialChangeEmail extends FormSpecialPage { return Status::newFatal( 'changeemail-nochange' ); } + // To prevent spam, rate limit adding a new address, but do + // not rate limit removing an address. + if ( $newaddr !== '' && $user->pingLimiter( 'changeemail' ) ) { + return Status::newFatal( 'actionthrottledtext' ); + } + $oldaddr = $user->getEmail(); $status = $user->setEmailWithConfirmation( $newaddr ); if ( !$status->isGood() ) { return $status; } + LoggerFactory::getInstance( 'authentication' )->info( + 'Changing email address for {user} from {oldemail} to {newemail}', [ + 'user' => $user->getName(), + 'oldemail' => $oldaddr, + 'newemail' => $newaddr, + ] + ); + Hooks::run( 'PrefsEmailAudit', [ $user, $oldaddr, $newaddr ] ); $user->saveSettings(); - MediaWiki\Auth\AuthManager::callLegacyAuthPlugin( 'updateExternalDB', [ $user ] ); return $status; }