Add SessionHandler::clearReauthentication()
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 20 Jan 2021 15:19:34 +0000 (16:19 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 21 Jan 2021 10:10:21 +0000 (11:10 +0100)
wcfsetup/install/files/lib/system/session/SessionHandler.class.php

index db465c41a434421b075a397f3d9e96332a062f4f..2e9c2f808d45c5b73b67e6f5c178613999e1cb3e 100644 (file)
@@ -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.
         */