diff --git a/api/src/cli/commands/users/passwd.ts b/api/src/cli/commands/users/passwd.ts index 25867d55a9..3d30401bed 100644 --- a/api/src/cli/commands/users/passwd.ts +++ b/api/src/cli/commands/users/passwd.ts @@ -17,7 +17,11 @@ export default async function usersPasswd({ email, password }: { email?: string; const schema = await getSchema(); const service = new UsersService({ schema, knex: database }); - const user = await service.knex.select('id').from('directus_users').where({ email }).first(); + const user = await service.knex + .select('id') + .from('directus_users') + .whereRaw('LOWER(??) = ?', ['email', email.toLowerCase()]) + .first(); if (user) { await service.knex('directus_users').update({ password: passwordHashed }).where({ id: user.id }); logger.info(`Password is updated for user ${user.id}`); diff --git a/api/src/services/users.ts b/api/src/services/users.ts index 1ea415a46e..5e99039162 100644 --- a/api/src/services/users.ts +++ b/api/src/services/users.ts @@ -357,7 +357,11 @@ export class UsersService extends ItemsService { const STALL_TIME = 500; const timeStart = performance.now(); - const user = await this.knex.select('status', 'password').from('directus_users').where({ email }).first(); + const user = await this.knex + .select('status', 'password') + .from('directus_users') + .whereRaw('LOWER(??) = ?', ['email', email.toLowerCase()]) + .first(); if (user?.status !== 'active') { await stall(STALL_TIME, timeStart);