Skip to content

Commit

Permalink
fix: fix issue with totp on 2FAS
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcath committed Oct 21, 2024
1 parent 5ef0442 commit df68abf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/routes/app.user.totp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ export const loader = async ({request}: LoaderFunctionArgs) => {
const genTotp = await generateTOTP()
const otpUri = getTOTPAuthUri({
...genTotp,
algorithm: 'SHA1',
accountName: totp.email,
issuer: 'Net Doc'
issuer: 'Net-Doc'
})
const dataURL = await toDataURL(otpUri)

Expand Down
17 changes: 9 additions & 8 deletions app/routes/app_.login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ export const action = async ({request}: ActionFunctionArgs) => {
}

if (user.totpSecret !== '' && otp !== null) {
const result =
(await verifyTOTP({
otp,
secret: user.totpSecret,
algorithm: user.totpAlgorithm === 'SHA1' ? 'SHA-1' : user.totpAlgorithm,
digits: user.totpDigits,
period: user.totpPeriod
})) !== null
const opts = {
otp,
secret: user.totpSecret,
algorithm: user.totpAlgorithm === 'SHA1' ? 'SHA-1' : user.totpAlgorithm,
digits: user.totpDigits,
period: user.totpPeriod
}

const result = (await verifyTOTP(opts)) !== null

if (!result) {
return json(
Expand Down

0 comments on commit df68abf

Please sign in to comment.