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 apps/frontend/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ Import direction is one-way and must stay that way: `api.ts` ← `authClient.ts`

**Refresh.** Access tokens last one hour. `AuthProvider` schedules a refresh ~2 minutes before expiry, and `authedFetch` refreshes reactively on a 401. Refresh is single-flight, so a burst of concurrent 401s produces one `POST /auth/refresh`. Cognito does not re-issue a refresh token, so `saveTokens` leaves the stored one alone when the response omits it.

**Guarding.** `src/app/components/AuthGate.tsx`, mounted once in `providers.tsx`, is the app's only route guard — static export means `middleware.ts` would never run. `src/lib/routes.ts` classifies routes and is **protected-by-default**: a new page under `src/app/` is guarded without opting in. Public routes are `/login`, `/forgot-password`, `/reset-password` (authenticated users get bounced off them). Open routes (`/help/**`) render for everyone, signed in or not, and skip the Chakra/Auth shell in `providers.tsx`: they are prerendered with real content, and Chakra's Emotion styles inline into SSR HTML and break hydration.
**Guarding.** `src/app/components/AuthGate.tsx`, mounted once in `providers.tsx`, is the app's only route guard — static export means `middleware.ts` would never run. `src/lib/routes.ts` classifies routes and is **protected-by-default**: a new page under `src/app/` is guarded without opting in. Public routes are `/login`, `/forgot-password`, `/reset-password` (authenticated users get bounced off them). Open routes (`/help/**`) render for everyone, signed in or not, and skip the Chakra/Auth shell in `providers.tsx`: they are prerendered with real content, and Chakra's Emotion styles inline into SSR HTML and break hydration. Which permission a page needs comes from `PAGE_PERMISSIONS` in `@branch/rbac`, so AuthGate, the Navbar and the lambdas all read one table. Always compare paths through `normalizePath` — `trailingSlash: true` means production sees `/login/` where dev and tests see `/login`. The public auth pages (`/login`, `/forgot-password`, `/reset-password`) share one layout: a `min-h-screen` centered wrapper around a `w-80` column; copy it for any new one.

**Help pages.** `/help` is the user guide, served at `branchaccounting.org/help`. Guides are data in `src/app/help/guides.ts` (numbered one-line steps; `[label](/path)` makes a link) and `[slug]/page.tsx` prerenders one page per guide via `generateStaticParams`. Screenshots live in `public/help/<guide>/`; `test/app/HelpGuides.test.ts` fails on a missing image or a link to a page that does not exist. Retake screenshots against a local stack with seeded demo data, never production. Which permission a page needs comes from `PAGE_PERMISSIONS` in `@branch/rbac`, so AuthGate, the Navbar and the lambdas all read one table. Always compare paths through `normalizePath` — `trailingSlash: true` means production sees `/login/` where dev and tests see `/login`.
**Help pages.** `/help` is the user guide, served at `branchaccounting.org/help`. Guides are data in `src/app/help/guides.ts` (numbered one-line steps; `[label](/path)` makes a link) and `[slug]/page.tsx` prerenders one page per guide via `generateStaticParams`. Screenshots live in `public/help/<guide>/`; `test/app/HelpGuides.test.ts` fails on a missing image or a link to a page that does not exist. Retake screenshots against a local stack with seeded demo data, never production.

## Permissions

Expand Down
Binary file modified apps/frontend/public/help/reset-password/forgot-link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/frontend/public/help/reset-password/request-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified apps/frontend/public/help/sign-in/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
115 changes: 63 additions & 52 deletions apps/frontend/src/app/forgot-password/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,81 +70,92 @@ export default function ForgotPasswordPage() {

if (step === 'done') {
return (
<div className="flex flex-col items-center text-center w-90">
<div className="flex flex-col items-start gap-6">
<h1 className="![font-family:var(--font-heading)] !text-[36px] !font-semibold">Password Changed</h1>
<h5 className="![font-family:var(--font-body)] !text-[16px] !font-bold text-center !text-core-black !mb-6">
<div className="flex min-h-screen items-center justify-center px-4">
<div className="flex flex-col items-center text-center w-80">
<h1 className="![font-family:var(--font-heading)] !text-[36px] !font-semibold !mb-6">Password Changed</h1>
<h5 className="![font-family:var(--font-body)] !text-[16px] !mb-10">
Your password has been successfully changed!
</h5>
<Link
href="/login"
className="![font-family:var(--font-body)] !rounded !bg-core-green !text-core-white w-full !px-4 !py-1.5 !text-center !font-bold"
>
Back to login
</Link>
</div>
<Link
href="/login"
className="![font-family:var(--font-body)] !rounded !bg-core-green !text-core-white w-full !px-4 !py-1.5 !mb-10 !text-center !font-bold"
>
Back to login
</Link>
</div>
);
}

if (step === 'confirm') {
return (
<div className="flex flex-col items-center text-center">
<h5 className="![font-family:var(--font-body)] !text-[16px] !mb-6">
We sent a verification code to {email}. Enter it below with your new password.
</h5>
<SetPasswordForm
includeCode
onSubmit={handleConfirm}
error={confirmError}
isLoading={isLoading}
/>
<button
type="button"
className="![font-family:var(--font-body)] !text-[16px] !font-bold !text-core-green !py-3 disabled:!text-black-500 disabled:cursor-not-allowed"
onClick={handleResend}
disabled={isLoading}
>
Resend code
</button>
<Link href="/login" className="![font-family:var(--font-body)] !text-[16px] !font-bold !text-core-green !py-3">
Back to login
</Link>
<div className="flex min-h-screen items-center justify-center px-4">
<div className="flex flex-col items-center text-center w-80">
<h5 className="![font-family:var(--font-body)] !text-[16px] !mb-6">
We sent a verification code to {email}. Enter it below with your new password.
</h5>
<SetPasswordForm
includeCode
onSubmit={handleConfirm}
error={confirmError}
isLoading={isLoading}
/>
<button
type="button"
className="![font-family:var(--font-body)] !text-[16px] !font-bold !text-core-green !py-3 disabled:!text-black-500 disabled:cursor-not-allowed"
onClick={handleResend}
disabled={isLoading}
>
Resend code
</button>
<Link href="/login" className="![font-family:var(--font-body)] !text-[16px] !font-bold !text-core-green !py-3">
Back to login
</Link>
</div>
</div>
);
}

return (
<div className="flex flex-col shrink-0 items-start gap-[30px]">
<div className="flex flex-col items-start gap-6">
<h1 className="![font-family:var(--font-heading)] !text-[36px] !font-bold">
Forgot your Password?
<div className="flex min-h-screen items-center justify-center px-4">
<form
onSubmit={(e) => {
e.preventDefault();
handleRequestReset();
}}
className="flex flex-col items-center text-center w-80"
>
<h1 className="![font-family:var(--font-heading)] !text-[36px] !font-semibold !mb-6">
Forgot password?
</h1>
<h5 className="![font-family:var(--font-body)] !text-[16px] !font-bold text-center w-[312px] !ml-[41px] !text-core-black">
Please enter the email address you&apos;d like your password reset information sent to
<h5 className="![font-family:var(--font-body)] !text-[16px] !mb-6">
Enter your email and we&apos;ll send you a code to reset your password.
</h5>
</div>
<div className="flex flex-col items-start ml-[26px] gap-9">
<TextInputField
label="Email"
required
placeholder="Enter email address"
errorMessage={emailError}
isError={!!emailError}
value={email}
onChange={(value) => setEmail(value)}
/>
<div className="flex flex-col w-full !mb-10">
<TextInputField
label="Email"
required
placeholder="Enter email address"
errorMessage={emailError}
isError={!!emailError}
value={email}
onChange={(value) => setEmail(value)}
type="email"
name="email"
autoComplete="username"
/>
</div>
<Button
className="![font-family:var(--font-body)] !text-[16px] !font-bold !bg-core-green !text-core-white !py-3 !px-[110px] !rounded !border-0"
onClick={handleRequestReset}
type="submit"
className="![font-family:var(--font-body)] !rounded !bg-core-green !text-core-white w-full !px-4 !py-1.5 !mb-10"
loading={isLoading}
>
Request reset code
</Button>
<Link href="/login" className="![font-family:var(--font-body)] !text-[16px] !font-bold !text-core-green !py-3 !px-[127px]">
<Link href="/login" className="!text-core-green !font-bold ![font-family:var(--font-body)] !text-[16px]">
Back to login
</Link>
</div>
</form>
</div>
);
}
7 changes: 5 additions & 2 deletions apps/frontend/src/app/help/guides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ export const GUIDES: Guide[] = [
image: '/help/reset-password/request-code.png',
alt: 'Forgot password page with Request reset code highlighted',
},
{ text: 'Enter the code from your email and a new password.' },
{ text: 'Click Reset Password.' },
{
text: 'Enter the code from your email and a new password, then click Reset Password.',
image: '/help/reset-password/new-password.png',
alt: 'Reset password form with Reset Password highlighted',
},
],
},
{
Expand Down
32 changes: 18 additions & 14 deletions apps/frontend/src/app/reset-password/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function ResetPasswordContent() {
// strings would just produce a confusing server-side error.
if (!email || !code) {
return (
<div className="flex flex-col items-center text-center w-90 gap-6">
<div className="flex min-h-screen items-center justify-center px-4">
<div className="flex flex-col items-center text-center w-80 gap-6">
<h1 className="![font-family:var(--font-heading)] !text-[36px] !font-semibold">
Link expired
</h1>
Expand All @@ -58,34 +59,37 @@ function ResetPasswordContent() {
Request a new reset link
</Link>
</div>
</div>
);
}

if (submitted) {
return (
<div className="flex flex-col items-center text-center w-90">
<div className="flex flex-col items-start gap-6">
<h1 className="![font-family:var(--font-heading)] !text-[36px] !font-semibold">Password Changed</h1>
<h5 className="![font-family:var(--font-body)] !text-[16px] !font-bold text-center !text-core-black !mb-6">
Your password has been successfully changed!
</h5>
</div>
<div className="flex min-h-screen items-center justify-center px-4">
<div className="flex flex-col items-center text-center w-80">
<h1 className="![font-family:var(--font-heading)] !text-[36px] !font-semibold !mb-6">Password Changed</h1>
<h5 className="![font-family:var(--font-body)] !text-[16px] !mb-10">
Your password has been successfully changed!
</h5>
<Button
className="![font-family:var(--font-body)] !rounded !bg-core-green !text-core-white w-full !px-4 !py-1.5 !mb-10"
className="![font-family:var(--font-body)] !rounded !bg-core-green !text-core-white w-full !px-4 !py-1.5"
onClick={() => router.push('/login')}
>
Back to login
</Button>
</div>
</div>
);
}

return (
<SetPasswordForm
onSubmit={handleResetPassword}
error={error}
isLoading={isLoading}
/>
<div className="flex min-h-screen items-center justify-center px-4">
<SetPasswordForm
onSubmit={handleResetPassword}
error={error}
isLoading={isLoading}
/>
</div>
);
}

Expand Down
Loading