Checkpoint: Le champ de connexion accepte maintenant un identifiant (ex: adminItinova) ou une adresse e-mail. Le backend recherche dans les deux cas. Le label et le placeholder ont été mis à jour.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import bcrypt from "bcryptjs";
|
||||
import { getDb } from "./db";
|
||||
import { localUsers } from "../drizzle/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { eq, or } from "drizzle-orm";
|
||||
import { SignJWT, jwtVerify } from "jose";
|
||||
import { ENV } from "./_core/env";
|
||||
|
||||
@@ -41,10 +41,17 @@ export async function loginLocalUser(email: string, password: string) {
|
||||
const db = await getDb();
|
||||
if (!db) throw new Error("Base de données indisponible");
|
||||
|
||||
// Recherche par e-mail (insensible à la casse) OU par identifiant exact
|
||||
const identifier = email.trim();
|
||||
const users = await db
|
||||
.select()
|
||||
.from(localUsers)
|
||||
.where(eq(localUsers.email, email.toLowerCase().trim()))
|
||||
.where(
|
||||
or(
|
||||
eq(localUsers.email, identifier.toLowerCase()),
|
||||
eq(localUsers.email, identifier)
|
||||
)
|
||||
)
|
||||
.limit(1);
|
||||
|
||||
const user = users[0];
|
||||
|
||||
Reference in New Issue
Block a user