diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index cb8cba30e2..7d20ede720 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -3788,7 +3788,7 @@ App::patch('/v1/account/mfa/recovery-codes') $queueForEvents->setParam('userId', $user->getId()); $document = new Document([ - 'recoveryCodes' => $mfaRecoveryCodes + 'recoveryCodes' => $mfaRecoveryCodes ]); $response->dynamic($document, Response::MODEL_MFA_RECOVERY_CODES); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 245cf5e98b..e91837c3ec 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -1711,7 +1711,7 @@ App::put('/v1/users/:userId/mfa/recovery-codes') $queueForEvents->setParam('userId', $user->getId()); $document = new Document([ - 'recoveryCodes' => $mfaRecoveryCodes + 'recoveryCodes' => $mfaRecoveryCodes ]); $response->dynamic($document, Response::MODEL_MFA_RECOVERY_CODES); diff --git a/app/controllers/shared/api/auth.php b/app/controllers/shared/api/auth.php index 5e9499600d..2f436a1436 100644 --- a/app/controllers/shared/api/auth.php +++ b/app/controllers/shared/api/auth.php @@ -13,17 +13,17 @@ App::init() ->groups(['mfaProtected']) ->inject('session') ->action(function (Document $session) { - $isSessionSafe = false; + $isSessionFresh = false; $lastUpdate = $session->getAttribute('mfaUpdatedAt'); if (!empty($lastUpdate)) { $now = DateTime::now(); $maxAllowedDate = DateTime::addSeconds($lastUpdate, Auth::MFA_RECENT_DURATION); // Maximum date until session is considered safe before asking for another challenge - $isSessionSafe = DateTime::formatTz($maxAllowedDate) >= DateTime::formatTz($now); + $isSessionFresh = DateTime::formatTz($maxAllowedDate) >= DateTime::formatTz($now); } - if (!$isSessionSafe) { + if (!$isSessionFresh) { throw new Exception(Exception::USER_CHALLENGE_REQUIRED); } }); diff --git a/src/Appwrite/Auth/Auth.php b/src/Appwrite/Auth/Auth.php index 4c5ebb5f0e..a25c6123ea 100644 --- a/src/Appwrite/Auth/Auth.php +++ b/src/Appwrite/Auth/Auth.php @@ -89,7 +89,7 @@ class Auth /** * MFA */ - public const MFA_RECENT_DURATION = 600; // 5 minutes + public const MFA_RECENT_DURATION = 1800; // 30 mins /** * @var string