Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/app/src/features/auth/auth-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ export function AuthScreen({ mode, inSettingsLayout = false }: { mode: AuthMode;
{mutation.isError && <p role="alert">{mutation.error.message}</p>}
{notice && <p role="status">{notice}</p>}
</form>
<nav className="mt-6 flex flex-wrap gap-4" aria-label="Account">
{mode !== "password" && <nav className="mt-6 flex flex-wrap gap-4" aria-label="Account">
{mode !== "login" && <Link to="/auth/login" search={{ connection: search.connection, returnTo: search.returnTo }}>Sign in</Link>}
{mode === "login" && <><Link to="/auth/signup" search={{ connection: search.connection, returnTo: search.returnTo }}>Create an account</Link><Link to="/auth/password-reset" search={{ connection: search.connection, returnTo: search.returnTo }}>Forgot password?</Link></>}
<Link to="/auth/verify/request" search={{ connection: search.connection, returnTo: search.returnTo }}>Resend verification</Link>
</nav>
</nav>}
</>;
return inSettingsLayout ? <SettingsLayout title={titles[mode]}>{content}</SettingsLayout> : <Page className="my-8 flex-none max-w-md rounded-2xl border border-stone-200 bg-white p-6 shadow-sm dark:border-slate-800 dark:bg-slate-900 sm:p-8">{content}</Page>;
}
33 changes: 33 additions & 0 deletions packages/app/test/auth.browser.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,39 @@ test("authenticated password route shows settings navigation with the active pas
await context.close();
});

test("authenticated password change is isolated from global auth navigation and reports invalidation", async () => {
const context = await browser.newContext();
const page = await context.newPage();
let active = true;
await page.route("**/api/v1/session", route => route.fulfill({ json: active ? {
authenticated: true, user: { id: "owner-a", email: "owner@example.test" },
workspace: { id: "workspace-a", name: "Workspace", role: "owner" }, capabilities: [],
} : { authenticated: false } }));
await page.route("**/api/v1/auth/password", async route => {
assert.deepEqual(route.request().postDataJSON(), { currentPassword: "old-test-password", password: "new-test-password" });
active = false;
await route.fulfill({ json: { ok: true }, headers: { "Set-Cookie": "factorize_session=; Max-Age=0; Path=/" } });
});
await page.goto(origin + "/settings/password");
assert.equal(await page.getByRole("navigation", { name: "Account" }).count(), 0);
await page.getByLabel("Current password", { exact: true }).fill("old-test-password");
await page.getByLabel("New password", { exact: true }).fill("new-test-password");
await page.getByRole("button", { name: "Continue", exact: true }).click();
await waitText(page, "status", "Password updated. Sign in with your new password.");
assert.equal(await page.getByRole("navigation", { name: "Account" }).count(), 0);
await context.close();
});

test("password recovery keeps its unauthenticated auth navigation", async () => {
const { page, context } = await pageFor("/auth/password-reset");
await page.getByRole("heading", { name: "Reset password" }).waitFor();
const account = page.getByRole("navigation", { name: "Account" });
await account.getByRole("link", { name: "Sign in", exact: true }).waitFor();
await account.getByRole("link", { name: "Resend verification", exact: true }).waitFor();
assert.equal(await page.getByLabel("Current password", { exact: true }).count(), 0);
await context.close();
});

test("logout refreshes session identity and removes the account display", async () => {
const context = await browser.newContext();
const page = await context.newPage();
Expand Down
Loading