From ec4d4d56a131f399590ddef750765eb324bfcb2c Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 3 Jun 2021 18:28:40 +0530 Subject: [PATCH 1/4] fix: ignore email case when creating account --- app/controllers/api/account.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index c3088c5b5d..446dfcf8f3 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -58,15 +58,18 @@ App::post('/v1/account') /** @var Appwrite\Database\Database $projectDB */ /** @var Appwrite\Event\Event $audits */ + $email = \strtolower($email); if ('console' === $project->getId()) { - $whitlistEmails = $project->getAttribute('authWhitelistEmails'); - $whitlistIPs = $project->getAttribute('authWhitelistIPs'); + $whitelistEmails = $project->getAttribute('authWhitelistEmails'); + $whitelistIPs = $project->getAttribute('authWhitelistIPs'); - if (!empty($whitlistEmails) && !\in_array($email, $whitlistEmails)) { + var_dump($whitelistEmails); + + if (!empty($whitelistEmails) && !\in_array($email, $whitelistEmails)) { throw new Exception('Console registration is restricted to specific emails. Contact your administrator for more information.', 401); } - if (!empty($whitlistIPs) && !\in_array($request->getIP(), $whitlistIPs)) { + if (!empty($whitelistIPs) && !\in_array($request->getIP(), $whitelistIPs)) { throw new Exception('Console registration is restricted to specific IPs. Contact your administrator for more information.', 401); } } From 26c46a2278a92d94a0e06c48d6254513d187c552 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 3 Jun 2021 18:33:51 +0530 Subject: [PATCH 2/4] fix: ignore email case when creating account --- app/controllers/api/account.php | 5 ++++- app/controllers/api/users.php | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 446dfcf8f3..efa9dc868c 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -177,6 +177,7 @@ App::post('/v1/account/sessions') /** @var MaxMind\Db\Reader $geodb */ /** @var Appwrite\Event\Event $audits */ + $email = \strtolower($email); $protocol = $request->getProtocol(); $profile = $projectDB->getCollectionFirst([ // Get user by email address 'limit' => 1, @@ -1089,6 +1090,7 @@ App::patch('/v1/account/email') throw new Exception('Invalid credentials', 401); } + $email = \strtolower($email); $profile = $projectDB->getCollectionFirst([ // Get user by email address 'limit' => 1, 'filters' => [ @@ -1411,7 +1413,8 @@ App::post('/v1/account/recovery') $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::$roles); $isAppUser = Auth::isAppUser(Authorization::$roles); - + + $email = \strtolower($email); $profile = $projectDB->getCollectionFirst([ // Get user by email address 'limit' => 1, 'filters' => [ diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 03543b7cd3..49e201e1d7 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -40,6 +40,7 @@ App::post('/v1/users') /** @var Appwrite\Utopia\Response $response */ /** @var Appwrite\Database\Database $projectDB */ + $email = \strtolower($email); $profile = $projectDB->getCollectionFirst([ // Get user by email address 'limit' => 1, 'filters' => [ From b954e148b535648d8c10c6f476080c21f3846eba Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 3 Jun 2021 19:01:00 +0530 Subject: [PATCH 3/4] feat: review comments --- app/controllers/api/account.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index efa9dc868c..13639c9125 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -63,8 +63,6 @@ App::post('/v1/account') $whitelistEmails = $project->getAttribute('authWhitelistEmails'); $whitelistIPs = $project->getAttribute('authWhitelistIPs'); - var_dump($whitelistEmails); - if (!empty($whitelistEmails) && !\in_array($email, $whitelistEmails)) { throw new Exception('Console registration is restricted to specific emails. Contact your administrator for more information.', 401); } From ef36e9ef49f356a22db7d591cbf351e5b8d09c52 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 4 Jun 2021 00:35:11 +0530 Subject: [PATCH 4/4] feat: review comments --- app/controllers/api/teams.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 685402b618..598783128e 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -285,7 +285,8 @@ App::post('/v1/teams/:teamId/memberships') $isPrivilegedUser = Auth::isPrivilegedUser(Authorization::$roles); $isAppUser = Auth::isAppUser(Authorization::$roles); - + + $email = \strtolower($email); $name = (empty($name)) ? $email : $name; $team = $projectDB->getDocument($teamId);