mirror of
https://github.com/fosrl/pangolin.git
synced 2026-09-01 16:59:22 +02:00
resolve security-key login only for a unique internal user
This commit is contained in:
@@ -533,18 +533,23 @@ export async function startAuthentication(
|
|||||||
|
|
||||||
// If email is provided, get security keys for that specific user
|
// If email is provided, get security keys for that specific user
|
||||||
if (email) {
|
if (email) {
|
||||||
const [user] = await db
|
const matchingUsers = await db
|
||||||
.select()
|
.select()
|
||||||
.from(users)
|
.from(users)
|
||||||
.where(eq(users.email, email))
|
.where(
|
||||||
.limit(1);
|
and(
|
||||||
|
eq(users.email, email.toLowerCase()),
|
||||||
|
eq(users.type, UserType.Internal)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
if (!user || user.type !== UserType.Internal) {
|
if (matchingUsers.length !== 1) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(HttpCode.BAD_REQUEST, "Invalid credentials")
|
createHttpError(HttpCode.BAD_REQUEST, "Invalid credentials")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const user = matchingUsers[0];
|
||||||
userId = user.userId;
|
userId = user.userId;
|
||||||
|
|
||||||
const userSecurityKeys = await db
|
const userSecurityKeys = await db
|
||||||
|
|||||||
Reference in New Issue
Block a user