From: Tim Düsterhus Date: Wed, 20 Jan 2021 15:19:34 +0000 (+0100) Subject: Add SessionHandler::clearReauthentication() X-Git-Tag: 5.4.0_Alpha_1~409^2^2~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7d50af22b70bdf855c3f7371d3ea78a113fe1331;p=GitHub%2FWoltLab%2FWCF.git Add SessionHandler::clearReauthentication() --- 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. */