From 7d50af22b70bdf855c3f7371d3ea78a113fe1331 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 20 Jan 2021 16:19:34 +0100 Subject: [PATCH] Add SessionHandler::clearReauthentication() --- .../system/session/SessionHandler.class.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php index db465c41a4..2e9c2f808d 100644 --- a/wcfsetup/install/files/lib/system/session/SessionHandler.class.php +++ b/wcfsetup/install/files/lib/system/session/SessionHandler.class.php @@ -1046,6 +1046,25 @@ final class SessionHandler extends SingletonFactory { ]); } + /** + * Clears that the user performed reauthentication successfully. + * + * After this method is called `needsReauthentication()` will return true until + * `registerReauthentication()` is called again. + * + * @see SessionHandler::registerReauthentication() + * @see SessionHandler::needsReauthentication() + * @throws \BadMethodCallException If the current user is a guest. + * @since 5.4 + */ + public function clearReauthentication(): void { + if (!$this->getUser()->userID) { + throw new \BadMethodCallException('The current user is a guest.'); + } + + $this->unregister(self::REAUTHENTICATION_KEY); + } + /** * Updates user session on shutdown. */ -- 2.20.1