From 04345cc085ff76f527ce3cd1e5628b869c786fa5 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 15 Jun 2022 13:17:33 +0530 Subject: [PATCH] fix: make email case-insensitive re #2361 Signed-off-by: Pranav C --- packages/nocodb/src/lib/models/User.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/lib/models/User.ts b/packages/nocodb/src/lib/models/User.ts index 3b383dc88c..de39bbe582 100644 --- a/packages/nocodb/src/lib/models/User.ts +++ b/packages/nocodb/src/lib/models/User.ts @@ -47,6 +47,9 @@ export default class User implements UserType { 'roles', 'token_version' ]); + + insertObj.email = insertObj.email?.toLowerCase(); + const { id } = await ncMeta.metaInsert2( null, null, @@ -76,6 +79,8 @@ export default class User implements UserType { 'roles', 'token_version' ]); + + updateObj.email = updateObj.email?.toLowerCase(); // get existing cache const keys = [ // update user: @@ -97,7 +102,8 @@ export default class User implements UserType { // set meta return await ncMeta.metaUpdate(null, null, MetaTable.USERS, updateObj, id); } - public static async getByEmail(email, ncMeta = Noco.ncMeta) { + public static async getByEmail(_email: string, ncMeta = Noco.ncMeta) { + const email = _email?.toLowerCase(); let user = email && (await NocoCache.get(