From 6df91a115f0ec8bd2da76b9aca6dc5ccd0c59494 Mon Sep 17 00:00:00 2001 From: Baw-Appie Date: Sat, 24 Aug 2024 16:57:49 +0900 Subject: [PATCH] chore: Refactor signin.ts for improved passkey support --- src/routes/v1/meiling/signin.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/routes/v1/meiling/signin.ts b/src/routes/v1/meiling/signin.ts index a2f6221..2fb9f86 100644 --- a/src/routes/v1/meiling/signin.ts +++ b/src/routes/v1/meiling/signin.ts @@ -434,11 +434,16 @@ please request this endpoint without challengeResponse field to request challeng const id = Buffer.from(idRaw, 'base64url').toString('base64'); + const userIds = targetUsers.filter((n) => n !== undefined).map((n) => (n as UserModel).id); + if (userIds.length === 0 && challengeResponse.response?.userHandle) { + const userHandle = Buffer.from(challengeResponse.response.userHandle, 'base64').toString('utf-8'); + userIds.push(userHandle); + } const webauthn = await getPrismaClient().authentication.findFirst({ where: { user: { id: { - in: targetUsers.filter((n) => n !== undefined).map((n) => (n as UserModel).id), + in: userIds, }, }, method: 'WEBAUTHN',