From 370e814b8c5f87b51eafb9e92a4d13ca98b3d030 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Wed, 21 Feb 2024 09:31:52 +0000 Subject: [PATCH] Update Factors Session Migration --- src/Appwrite/Migration/Version/V20.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Migration/Version/V20.php b/src/Appwrite/Migration/Version/V20.php index f43da066c4..1796629db0 100644 --- a/src/Appwrite/Migration/Version/V20.php +++ b/src/Appwrite/Migration/Version/V20.php @@ -540,7 +540,14 @@ class V20 extends Migration $duration = $this->project->getAttribute('auths', [])['duration'] ?? Auth::TOKEN_EXPIRATION_LOGIN_LONG; $expire = DateTime::addSeconds(new \DateTime(), $duration); $document->setAttribute('expire', $expire); - $document->setAttribute('factors', ['email']); + + $factors = match ($document->getAttribute('provider')) { + Auth::SESSION_PROVIDER_ANONYMOUS => ['anonymous'], + Auth::SESSION_PROVIDER_PHONE => ['phone'], + default => ['email'], + }; + + $document->setAttribute('factors', $factors); break; } return $document;