From 3d17b64eacff19fc93d89d23e77bd865cc218f2c Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Tue, 23 Apr 2024 16:24:05 +0900 Subject: [PATCH 1/2] Add Null check before we access factors --- app/controllers/shared/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 7c2f08c70..9e2812f63 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -290,7 +290,7 @@ App::init() $minimumFactors = ($mfaEnabled && $hasMoreFactors) ? 2 : 1; if (!in_array('mfa', $route->getGroups())) { - if ($session && \count($session->getAttribute('factors')) < $minimumFactors) { + if ($session && !empty($session->getAttribute('factors')) && \count($session->getAttribute('factors')) < $minimumFactors) { throw new Exception(Exception::USER_MORE_FACTORS_REQUIRED); } } From 089af4e137340de666b8eacd1a29d793e168834a Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Tue, 23 Apr 2024 16:34:12 +0900 Subject: [PATCH 2/2] Update app/controllers/shared/api.php Co-authored-by: Jake Barnby --- app/controllers/shared/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 9e2812f63..fdaa98212 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -290,7 +290,7 @@ App::init() $minimumFactors = ($mfaEnabled && $hasMoreFactors) ? 2 : 1; if (!in_array('mfa', $route->getGroups())) { - if ($session && !empty($session->getAttribute('factors')) && \count($session->getAttribute('factors')) < $minimumFactors) { + if ($session && \count($session->getAttribute('factors', [])) < $minimumFactors) { throw new Exception(Exception::USER_MORE_FACTORS_REQUIRED); } }