Skip to content

Commit

Permalink
feat: require tfa to fetch passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcath committed Mar 5, 2024
1 parent f615741 commit 1f4e906
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/routes/api.password.$password.get.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ export const loader = async ({request, params}: LoaderFunctionArgs) => {

const prisma = getPrisma()

const userTotp = await prisma.user.findFirstOrThrow({
where: {id: user.id},
select: {id: true, totpSecret: true}
})

if (userTotp.totpSecret === '') {
return json({password: "Can't fetch password without 2FA on your account"})
}

const password = await prisma.password.findFirstOrThrow({
where: {id: params.password}
})
Expand Down

0 comments on commit 1f4e906

Please sign in to comment.