From 53adb4e1142df5fcd87bbfc007a9505375714b19 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 17 Nov 2022 12:38:09 +0100 Subject: [PATCH] fix: migration for oauth providers --- src/Appwrite/Migration/Version/V16.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Appwrite/Migration/Version/V16.php b/src/Appwrite/Migration/Version/V16.php index db13e6d182..070b8e7d92 100644 --- a/src/Appwrite/Migration/Version/V16.php +++ b/src/Appwrite/Migration/Version/V16.php @@ -5,6 +5,7 @@ namespace Appwrite\Migration\Version; use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; use Utopia\CLI\Console; +use Utopia\Config\Config; use Utopia\Database\Database; use Utopia\Database\Document; @@ -119,6 +120,20 @@ class V16 extends Migration $document->setAttribute('auths', array_merge($document->getAttribute('auths', []), [ 'duration' => Auth::TOKEN_EXPIRATION_LOGIN_LONG ])); + + + $authProviders = $document->getAttribute('authProviders', []); + + foreach (Config::getParam('providers') as $provider => $value) { + if (!$value['enabled']) { + continue; + } + + if (($authProviders[$provider . 'Appid'] ?? false) && ($authProviders[$provider . 'Secret'] ?? false)) { + $authProviders[$provider . 'Enabled'] = true; + } + } + break; }