Skip to content

Commit 4fc5274

Browse files
Passkey deletion ownership (#698)
Co-authored-by: seer-by-sentry[bot] <157164994+seer-by-sentry[bot]@users.noreply.github.com>
1 parent 27e7aca commit 4fc5274

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

app/routes/me_.passkeys.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,19 @@ export async function action({ request }: Route.ActionArgs) {
3030
const passkeyId = formData.get('passkeyId')
3131

3232
if (intent === 'delete' && typeof passkeyId === 'string') {
33+
// First verify the passkey exists and belongs to the user
34+
const passkey = await prisma.passkey.findUnique({
35+
where: { id: passkeyId },
36+
select: { userId: true },
37+
})
38+
39+
if (!passkey || passkey.userId !== user.id) {
40+
throw new Response('Passkey not found', { status: 404 })
41+
}
42+
43+
// Delete using only the unique identifier
3344
await prisma.passkey.delete({
34-
where: {
35-
id: passkeyId,
36-
userId: user.id, // Ensure the passkey belongs to the user
37-
},
45+
where: { id: passkeyId },
3846
})
3947
}
4048

0 commit comments

Comments
 (0)