Skip to content

Commit 419e7df

Browse files
committed
02/02: generate OTP from the same config
1 parent d97bfcb commit 419e7df

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

exercises/02.authentication/02.solution.2fa/tests/db-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ export async function createVerification(input: {
5858
totp: Awaited<ReturnType<typeof generateTOTP>>
5959
userId: string
6060
}) {
61-
const { otp, ...totp } = input.totp
61+
const { otp, ...totpConfig } = input.totp
6262
const verification = await prisma.verification.create({
6363
data: {
64-
...totp,
65-
type: '2fa-verify',
64+
...totpConfig,
65+
type: '2fa',
6666
target: input.userId,
6767
},
6868
})

exercises/02.authentication/02.solution.2fa/tests/e2e/authentication-2fa.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ test('authenticates using two-factor authentication', async ({
2121
await page.getByLabel('Password').fill(user.password)
2222
await page.getByRole('button', { name: 'Log in' }).click()
2323

24+
await expect(
25+
page.getByRole('heading', { name: 'Check your 2FA app' }),
26+
).toBeVisible()
27+
2428
await page
2529
.getByRole('textbox', { name: /code/i })
26-
.fill((await generateTOTP()).otp)
30+
.fill((await generateTOTP(totp)).otp)
2731

2832
await page.getByRole('button', { name: 'Submit' }).click()
2933

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)