From 68f5b23fc51c303738df7111a743f0ba4e93c425 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 4 Apr 2024 19:01:43 +0200 Subject: [PATCH] Implement method 'Auth#isWaitingForSecondFactor' --- src/Auth.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Auth.php b/src/Auth.php index 7df6e5e..53effd1 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -2192,6 +2192,15 @@ final class Auth extends UserManager { return $this->ipAddress; } + /** + * Returns whether we are waiting for the user to complete the second factor of (two-factor) authentification, them having successfully completed the first factor before + * + * @return bool + */ + public function isWaitingForSecondFactor() { + return !empty($_SESSION[self::SESSION_FIELD_AWAITING_2FA_UNTIL]) && $_SESSION[self::SESSION_FIELD_AWAITING_2FA_UNTIL] >= \time(); + } + /** * Performs throttling or rate limiting using the token bucket algorithm (inverse leaky bucket algorithm) *