From 6d07c9193359b776f1d2ef798c4b22d63bebb24d Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 12 Jun 2023 14:29:46 +0530 Subject: [PATCH 1/3] fix: convert to lower case and compare Signed-off-by: Pranav C --- packages/nocodb/src/services/auth.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nocodb/src/services/auth.service.ts b/packages/nocodb/src/services/auth.service.ts index 287cb16391..9771d36b5c 100644 --- a/packages/nocodb/src/services/auth.service.ts +++ b/packages/nocodb/src/services/auth.service.ts @@ -13,7 +13,9 @@ import type { CreateUserDto } from '../controllers/auth.controller'; export class AuthService { constructor(private usersService: UsersService) {} - async validateUser(email: string, pass: string): Promise { + async validateUser(_email: string, pass: string): Promise { + const email = _email.toLowerCase(); + const user = await this.usersService.findOne(email); if (user) { const { password, salt, ...result } = user; From 3990facff0fc9cb103c4e1bd3b52e6cb79550ad4 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 12 Jun 2023 14:30:48 +0530 Subject: [PATCH 2/3] refactor: move the logic to findOne Signed-off-by: Pranav C --- packages/nocodb/src/services/auth.service.ts | 4 +--- packages/nocodb/src/services/users/users.service.ts | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/services/auth.service.ts b/packages/nocodb/src/services/auth.service.ts index 9771d36b5c..287cb16391 100644 --- a/packages/nocodb/src/services/auth.service.ts +++ b/packages/nocodb/src/services/auth.service.ts @@ -13,9 +13,7 @@ import type { CreateUserDto } from '../controllers/auth.controller'; export class AuthService { constructor(private usersService: UsersService) {} - async validateUser(_email: string, pass: string): Promise { - const email = _email.toLowerCase(); - + async validateUser(email: string, pass: string): Promise { const user = await this.usersService.findOne(email); if (user) { const { password, salt, ...result } = user; diff --git a/packages/nocodb/src/services/users/users.service.ts b/packages/nocodb/src/services/users/users.service.ts index 0753329060..f76415708b 100644 --- a/packages/nocodb/src/services/users/users.service.ts +++ b/packages/nocodb/src/services/users/users.service.ts @@ -32,7 +32,8 @@ import type { export class UsersService { constructor(private metaService: MetaService) {} - async findOne(email: string) { + async findOne(_email: string) { + const email = _email.toLowerCase(); const user = await this.metaService.metaGet(null, null, MetaTable.USERS, { email, }); From ea834f900761dd0b3a66430d539290bd40df75ba Mon Sep 17 00:00:00 2001 From: Pranav C Date: Mon, 12 Jun 2023 14:47:04 +0530 Subject: [PATCH 3/3] fix: convert email to lowercase before insertion Signed-off-by: Pranav C --- packages/nocodb/src/services/users/users.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nocodb/src/services/users/users.service.ts b/packages/nocodb/src/services/users/users.service.ts index f76415708b..6d1305173b 100644 --- a/packages/nocodb/src/services/users/users.service.ts +++ b/packages/nocodb/src/services/users/users.service.ts @@ -51,7 +51,7 @@ export class UsersService { email: string; lastname: any; }) { - return this.metaService.metaInsert2(null, null, MetaTable.USERS, param); + return this.metaService.metaInsert2(null, null, MetaTable.USERS, { ...param, email: param.email?.toLowerCase() }); } async registerNewUserIfAllowed({