1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-11 23:23:59 +00:00

feat: add support for email verification (#1223)

This commit is contained in:
Elias Schneider
2026-01-11 12:31:26 +01:00
committed by GitHub
parent e955118a6f
commit 1e7442f5df
60 changed files with 1452 additions and 700 deletions

View File

@@ -1,5 +1,5 @@
import test, { expect } from '@playwright/test';
import { users } from '../data';
import { emailVerificationTokens, users } from '../data';
import authUtil from '../utils/auth.util';
import { cleanupBackend } from '../utils/cleanup.util';
import passkeyUtil from '../utils/passkey.util';
@@ -128,3 +128,31 @@ test('Generate own one time access token as non admin', async ({ page, context }
await page.goto(link!);
await page.waitForURL('/settings/account');
});
test('Email verification succeeds', async ({ page, context }) => {
await context.clearCookies();
const token = emailVerificationTokens.find((t) => !t.expired)!.token;
await page.goto(`/verify-email?token=${token}`);
await (await passkeyUtil.init(page)).addPasskey('craig');
await page.getByRole('button', { name: 'Authenticate' }).click();
await page.waitForURL('/settings/account?emailVerificationState=success');
await expect(page.getByText('Email Verified Successfully')).toBeVisible();
});
test('Email verification fails with expired token', async ({ page, context }) => {
await context.clearCookies();
const token = emailVerificationTokens.find((t) => t.expired)!.token;
await page.goto(`/verify-email?token=${token}`);
await (await passkeyUtil.init(page)).addPasskey('craig');
await page.getByRole('button', { name: 'Authenticate' }).click();
await page.waitForURL(
'/settings/account?emailVerificationState=Invalid+email+verification+token'
);
await expect(page.getByText('Invalid email verification token')).toBeVisible();
});

View File

@@ -113,7 +113,7 @@ test('End session without id token hint shows confirmation page', async ({ page
await expect(page).toHaveURL('/logout');
await page.getByRole('button', { name: 'Sign out' }).click();
await expect(page).toHaveURL('/login');
await expect(page).toHaveURL('/login?redirect=%2F');
});
test('End session with id token hint redirects to callback URL', async ({ page }) => {