From 72e2661facb36e658db82eb43f849cc6a8bd0b39 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 1 Jul 2021 14:59:02 +0200 Subject: [PATCH] Cancel lost password requests when the user logs in Resolves #3922 --- com.woltlab.wcf/eventListener.xml | 5 +++ ...rLoginCancelLostPasswordListener.class.php | 37 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/event/listener/UserLoginCancelLostPasswordListener.class.php diff --git a/com.woltlab.wcf/eventListener.xml b/com.woltlab.wcf/eventListener.xml index 3fb2f656d5..20179f8bde 100644 --- a/com.woltlab.wcf/eventListener.xml +++ b/com.woltlab.wcf/eventListener.xml @@ -39,5 +39,10 @@ wcf\system\event\listener\UserLinkHtmlInputNodeProcessorListener all + + wcf\system\user\authentication\event\UserLoggedIn + wcf\system\event\listener\UserLoginCancelLostPasswordListener + all + diff --git a/wcfsetup/install/files/lib/system/event/listener/UserLoginCancelLostPasswordListener.class.php b/wcfsetup/install/files/lib/system/event/listener/UserLoginCancelLostPasswordListener.class.php new file mode 100644 index 0000000000..2ce062d429 --- /dev/null +++ b/wcfsetup/install/files/lib/system/event/listener/UserLoginCancelLostPasswordListener.class.php @@ -0,0 +1,37 @@ + + * @package WoltLabSuite\Core\System\Event\Listener + * @since 5.5 + */ +final class UserLoginCancelLostPasswordListener +{ + public function __invoke(UserLoggedIn $event) + { + $user = $event->getUser(); + if (!$user->lostPasswordKey) { + return; + } + + (new UserAction( + [$user], + 'update', + [ + 'data' => [ + 'lastLostPasswordRequestTime' => 0, + 'lostPasswordKey' => '', + ], + ] + ))->executeAction(); + } +} -- 2.20.1