Add support for OTPs and enhance sensitive apis with OTP verification (#191)
One-Time Password (OTP) package added with comprehensive token management, including OTP verification for team account deletion and ownership transfer.
This commit is contained in:
committed by
GitHub
parent
20f7fd2c22
commit
d31f3eb993
@@ -25,7 +25,7 @@ export class AuthPageObject {
|
||||
}
|
||||
|
||||
async signIn(params: { email: string; password: string }) {
|
||||
await this.page.waitForTimeout(1000);
|
||||
await this.page.waitForTimeout(500);
|
||||
|
||||
await this.page.fill('input[name="email"]', params.email);
|
||||
await this.page.fill('input[name="password"]', params.password);
|
||||
@@ -37,7 +37,7 @@ export class AuthPageObject {
|
||||
password: string;
|
||||
repeatPassword: string;
|
||||
}) {
|
||||
await this.page.waitForTimeout(1000);
|
||||
await this.page.waitForTimeout(500);
|
||||
|
||||
await this.page.fill('input[name="email"]', params.email);
|
||||
await this.page.fill('input[name="password"]', params.password);
|
||||
@@ -50,6 +50,7 @@ export class AuthPageObject {
|
||||
email: string,
|
||||
params: {
|
||||
deleteAfter: boolean;
|
||||
subject?: string;
|
||||
} = {
|
||||
deleteAfter: true,
|
||||
},
|
||||
@@ -79,6 +80,10 @@ export class AuthPageObject {
|
||||
});
|
||||
|
||||
await this.visitConfirmEmailLink(email);
|
||||
|
||||
return {
|
||||
email,
|
||||
};
|
||||
}
|
||||
|
||||
async updatePassword(password: string) {
|
||||
|
||||
@@ -51,6 +51,23 @@ test.describe('Auth flow', () => {
|
||||
|
||||
expect(page.url()).toContain('/');
|
||||
});
|
||||
|
||||
test('will sign out using the dropdown', async ({ page }) => {
|
||||
const auth = new AuthPageObject(page);
|
||||
|
||||
await page.goto('/home/settings');
|
||||
|
||||
await auth.signIn({
|
||||
email: 'test@makerkit.dev',
|
||||
password: 'testingpassword',
|
||||
});
|
||||
|
||||
await page.waitForURL('/home/settings');
|
||||
|
||||
await auth.signOut();
|
||||
|
||||
await page.waitForURL('/');
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Protected routes', () => {
|
||||
|
||||
@@ -2,35 +2,60 @@ import { expect, test } from '@playwright/test';
|
||||
|
||||
import { AuthPageObject } from './auth.po';
|
||||
|
||||
const email = 'owner@makerkit.dev';
|
||||
const newPassword = (Math.random() * 10000).toString();
|
||||
|
||||
test.describe('Password Reset Flow', () => {
|
||||
test.describe.configure({ mode: 'serial' });
|
||||
|
||||
test('will reset the password and sign in with new one', async ({ page }) => {
|
||||
const auth = new AuthPageObject(page);
|
||||
|
||||
await page.goto('/auth/password-reset');
|
||||
let email = '';
|
||||
|
||||
await page.fill('[name="email"]', email);
|
||||
await page.click('[type="submit"]');
|
||||
await expect(async () => {
|
||||
email = `test-${Math.random() * 10000}@makerkit.dev`;
|
||||
|
||||
await auth.visitConfirmEmailLink(email);
|
||||
await page.goto('/auth/sign-up');
|
||||
|
||||
await page.waitForURL('/update-password');
|
||||
await auth.signUp({
|
||||
email,
|
||||
password: 'password',
|
||||
repeatPassword: 'password',
|
||||
});
|
||||
|
||||
await auth.updatePassword(newPassword);
|
||||
await auth.visitConfirmEmailLink(email, {
|
||||
deleteAfter: true,
|
||||
subject: 'Confirm your email',
|
||||
});
|
||||
|
||||
await page
|
||||
.locator('a', {
|
||||
hasText: 'Back to Home Page',
|
||||
})
|
||||
.click();
|
||||
await page.context().clearCookies();
|
||||
await page.reload();
|
||||
|
||||
await page.waitForURL('/home');
|
||||
await page.goto('/auth/password-reset');
|
||||
|
||||
await auth.signOut();
|
||||
await page.fill('[name="email"]', email);
|
||||
await page.click('[type="submit"]');
|
||||
|
||||
await auth.visitConfirmEmailLink(email, {
|
||||
deleteAfter: true,
|
||||
subject: 'Reset your password',
|
||||
});
|
||||
|
||||
await page.waitForURL('/update-password', {
|
||||
timeout: 1000,
|
||||
});
|
||||
|
||||
await auth.updatePassword(newPassword);
|
||||
|
||||
await page
|
||||
.locator('a', {
|
||||
hasText: 'Back to Home Page',
|
||||
})
|
||||
.click();
|
||||
|
||||
await page.waitForURL('/home');
|
||||
}).toPass();
|
||||
|
||||
await page.context().clearCookies();
|
||||
await page.reload();
|
||||
|
||||
await page
|
||||
.locator('a', {
|
||||
@@ -43,6 +68,8 @@ test.describe('Password Reset Flow', () => {
|
||||
password: newPassword,
|
||||
});
|
||||
|
||||
await page.waitForURL('/home');
|
||||
await page.waitForURL('/home', {
|
||||
timeout: 2000,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user