Browse Source

fix: make email case-insensitive

re #2361

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2376/head
Pranav C 2 years ago
parent
commit
04345cc085
  1. 8
      packages/nocodb/src/lib/models/User.ts

8
packages/nocodb/src/lib/models/User.ts

@ -47,6 +47,9 @@ export default class User implements UserType {
'roles', 'roles',
'token_version' 'token_version'
]); ]);
insertObj.email = insertObj.email?.toLowerCase();
const { id } = await ncMeta.metaInsert2( const { id } = await ncMeta.metaInsert2(
null, null,
null, null,
@ -76,6 +79,8 @@ export default class User implements UserType {
'roles', 'roles',
'token_version' 'token_version'
]); ]);
updateObj.email = updateObj.email?.toLowerCase();
// get existing cache // get existing cache
const keys = [ const keys = [
// update user:<id> // update user:<id>
@ -97,7 +102,8 @@ export default class User implements UserType {
// set meta // set meta
return await ncMeta.metaUpdate(null, null, MetaTable.USERS, updateObj, id); 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 = let user =
email && email &&
(await NocoCache.get( (await NocoCache.get(

Loading…
Cancel
Save