resolve security-key login only for a unique internal user

This commit is contained in:
miloschwartz
2026-08-31 14:39:36 -04:00
parent 8aef14cf9f
commit 39722d30af
+9 -4
View File
@@ -533,18 +533,23 @@ export async function startAuthentication(
// If email is provided, get security keys for that specific user
if (email) {
const [user] = await db
const matchingUsers = await db
.select()
.from(users)
.where(eq(users.email, email))
.limit(1);
.where(
and(
eq(users.email, email.toLowerCase()),
eq(users.type, UserType.Internal)
)
);
if (!user || user.type !== UserType.Internal) {
if (matchingUsers.length !== 1) {
return next(
createHttpError(HttpCode.BAD_REQUEST, "Invalid credentials")
);
}
const user = matchingUsers[0];
userId = user.userId;
const userSecurityKeys = await db