From 5ef196ec9abc15f6feb55bd951e128afd096dc52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 3 Jul 2024 07:11:15 +0000 Subject: [PATCH] PR review changes --- .env | 1 + app/config/variables.php | 9 +++++++++ app/controllers/api/projects.php | 6 +++--- app/init.php | 2 +- app/views/install/compose.phtml | 1 + docker-compose.yml | 1 + 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 19215e23ee..9cccf5ee7e 100644 --- a/.env +++ b/.env @@ -4,6 +4,7 @@ _APP_LOCALE=en _APP_WORKER_PER_CORE=6 _APP_CONSOLE_WHITELIST_ROOT=disabled _APP_CONSOLE_WHITELIST_EMAILS= +_APP_CONSOLE_SESSION_ALERTS=enabled _APP_CONSOLE_WHITELIST_IPS= _APP_CONSOLE_COUNTRIES_DENYLIST=AQ _APP_CONSOLE_HOSTNAMES=localhost,appwrite.io,*.appwrite.io diff --git a/app/config/variables.php b/app/config/variables.php index ef30d4d17b..b986ce4247 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -250,6 +250,15 @@ return [ 'question' => '', 'filter' => '' ], + [ + 'name' => '_APP_CONSOLE_SESSION_ALERTS', + 'description' => 'This option allows you configure if a new login in the Appwrite Console should send an alert email to the user. It\'s disabled by default with value "disabled", and to enable it, pass value "enabled".', + 'introduction' => '1.6.0', + 'default' => 'disabled', + 'required' => false, + 'question' => '', + 'filter' => '' + ], ], ], [ diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 1533456f03..ff22337481 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -616,10 +616,10 @@ App::patch('/v1/projects/:projectId/auth/session-alerts') ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_PROJECT) ->param('projectId', '', new UID(), 'Project unique ID.') - ->param('sessionAlerts', false, new Boolean(true), 'Set to true to enable session emails.') + ->param('alerts', false, new Boolean(true), 'Set to true to enable session emails.') ->inject('response') ->inject('dbForConsole') - ->action(function (string $projectId, bool $sessionAlerts, Response $response, Database $dbForConsole) { + ->action(function (string $projectId, bool $alerts, Response $response, Database $dbForConsole) { $project = $dbForConsole->getDocument('projects', $projectId); @@ -628,7 +628,7 @@ App::patch('/v1/projects/:projectId/auth/session-alerts') } $auths = $project->getAttribute('auths', []); - $auths['sessionAlerts'] = $sessionAlerts; + $auths['sessionAlerts'] = $alerts; $dbForConsole->updateDocument('projects', $project->getId(), $project ->setAttribute('auths', $auths)); diff --git a/app/init.php b/app/init.php index 2291389c23..fe28407724 100644 --- a/app/init.php +++ b/app/init.php @@ -1323,7 +1323,7 @@ App::setResource('console', function () { 'invites' => System::getEnv('_APP_CONSOLE_INVITES', 'enabled') === 'enabled', 'limit' => (System::getEnv('_APP_CONSOLE_WHITELIST_ROOT', 'enabled') === 'enabled') ? 1 : 0, // limit signup to 1 user 'duration' => Auth::TOKEN_EXPIRATION_LOGIN_LONG, // 1 Year in seconds - 'sessionAlerts' => true + 'sessionAlerts' => System::getEnv('_APP_CONSOLE_SESSION_ALERTS', 'disabled') === 'enabled' ], 'authWhitelistEmails' => (!empty(System::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null))) ? \explode(',', System::getEnv('_APP_CONSOLE_WHITELIST_EMAILS', null)) : [], 'authWhitelistIPs' => (!empty(System::getEnv('_APP_CONSOLE_WHITELIST_IPS', null))) ? \explode(',', System::getEnv('_APP_CONSOLE_WHITELIST_IPS', null)) : [], diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index a6e3521e52..2f1be0b2dd 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -75,6 +75,7 @@ $image = $this->getParam('image', ''); - _APP_LOCALE - _APP_CONSOLE_WHITELIST_ROOT - _APP_CONSOLE_WHITELIST_EMAILS + - _APP_CONSOLE_SESSION_ALERTS - _APP_CONSOLE_WHITELIST_IPS - _APP_CONSOLE_HOSTNAMES - _APP_SYSTEM_EMAIL_NAME diff --git a/docker-compose.yml b/docker-compose.yml index d5d27ce461..1bcbd78a12 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -98,6 +98,7 @@ services: - _APP_LOCALE - _APP_CONSOLE_WHITELIST_ROOT - _APP_CONSOLE_WHITELIST_EMAILS + - _APP_CONSOLE_SESSION_ALERTS - _APP_CONSOLE_WHITELIST_IPS - _APP_CONSOLE_HOSTNAMES - _APP_SYSTEM_EMAIL_NAME