1
0
Fork 0
mirror of synced 2024-06-29 03:30:34 +12:00

Merge pull request #1243 from appwrite/fix-1240-ignore-email-case

fix: ignore email case when creating account
This commit is contained in:
Eldad A. Fux 2021-06-07 23:57:30 +03:00 committed by GitHub
commit 8ee8de978a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View file

@ -58,15 +58,16 @@ 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)) {
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);
}
}
@ -174,6 +175,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,
@ -1086,6 +1088,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' => [
@ -1408,7 +1411,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' => [

View file

@ -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);

View file

@ -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' => [