From 70ea6734e78c0af6ab715d2ca0e5a22dcb8b7ba5 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Tue, 6 Feb 2024 19:22:54 +0000 Subject: [PATCH] Add expire defaults --- src/Appwrite/Migration/Version/V20.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Appwrite/Migration/Version/V20.php b/src/Appwrite/Migration/Version/V20.php index ffe8583e1f..505fc3a7fd 100644 --- a/src/Appwrite/Migration/Version/V20.php +++ b/src/Appwrite/Migration/Version/V20.php @@ -2,12 +2,14 @@ namespace Appwrite\Migration\Version; +use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; use Exception; use PDOException; use Throwable; use Utopia\CLI\Console; use Utopia\Database\Database; +use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Duplicate; @@ -525,6 +527,11 @@ class V20 extends Migration $this->projectDB->createDocument('targets', $target); } break; + case 'sessions': + $duration = $this->project->getAttribute('auths', [])['duration'] ?? Auth::TOKEN_EXPIRATION_LOGIN_LONG; + $expire = DateTime::addSeconds(new \DateTime(), $duration); + $document->setAttribute('expire', $expire); + break; } return $document; }