From 834fad78e1af3a3ac76f4f0f9cb53824fc00cdef Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:20:52 -0400 Subject: [PATCH] refactor: Variables names --- app/controllers/api/account.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index af4e60364e..e2d6788f96 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -177,6 +177,12 @@ $createSession = function (string $userId, string $secret, Request $request, Res default => throw new Exception(Exception::USER_INVALID_TOKEN) }); + $sendAlert = (match ($verifiedToken->getAttribute('type')) { + Auth::TOKEN_TYPE_MAGIC_URL, + Auth::TOKEN_TYPE_EMAIL => false, + default => true + }); + $session = new Document(array_merge( [ '$id' => ID::unique(), @@ -223,7 +229,7 @@ $createSession = function (string $userId, string $secret, Request $request, Res throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed saving user to DB'); } - if ($project->getAttribute('auths', [])['sessionAlerts'] ?? false) { + if (($project->getAttribute('auths', [])['sessionAlerts'] ?? false) && $sendAlert) { if ($dbForProject->count('sessions', [ Query::equal('userId', [$user->getId()]), ]) !== 1) {