I'll add an authentication layer (login + register + session) without touching any of the existing features. Let me check the current App shell first.
I'll build:
- Auth context/provider — session persisted in localStorage, register/login/logout, mock user store.
- Auth screens — Login + Register with the same design language (split hero + form).
- Route guard — App renders auth screens when logged out, existing dashboard when logged in.
- Navbar profile menu — wire the "Sign out" action + show the real user name/initials.
No existing feature is altered.
Now the auth screens (Login + Register) sharing a split layout.
Now the AuthGate that renders login/register when signed-out. Then wire the provider into main.tsx and hook up the Navbar sign-out.
Now wire the Navbar to show the real user + working sign-out (small, non-feature-altering additions).
Now use it inside the component:
Now wire the profile menu items to include the account info and hook Sign out to logout:
Also greet the logged-in user on the Dashboard (small polish that uses the new auth without changing dashboard features):
Now let's build and verify.
Build passes cleanly. Here's the authentication layer that was added — no existing feature was modified, only wrapped:
Authentication System
src/auth/AuthContext.tsx — session provider
- Persists a user registry in
localStorage and the active session in either localStorage (if "Keep me signed in") or sessionStorage (per-tab).
- Passwords are hashed (djb2) before storage — never stored in plaintext.
- Exposes
login, register, logout, user, ready.
- Seeds a demo user so reviewers can log in immediately.
src/auth/AuthLayout.tsx — shared split-screen shell
- Left: dark sage-to-charcoal hero with brand mark, feature bullets (Security, Cashflow, Auto-reconcile), decorative blurred rings and dot grid.
- Right: form column with mobile brand fallback. Matches the rest of the app's design language (Abhaya Libre display, Plus Jakarta Sans body, sage focus rings).
src/auth/Login.tsx
- Email + password fields with icon adornments, show/hide toggle, "Keep me signed in", forgot-password link.
- Inline error toast, spinner state on the primary button, social sign-in buttons (visual), and a demo-credentials card with one-click "Autofill".
- Switches to Register via inline link.
src/auth/Register.tsx
- Name, company, email, password with a live 4-segment strength meter and rule checklist (8+ chars, uppercase, number, symbol).
- Terms checkbox, spinner state, duplicate-email guard, immediate sign-in on success.
src/auth/AuthGate.tsx — the router
- Shows a subtle "Preparing your workspace…" spinner while the session boots.
- If signed out → renders Login/Register.
- If signed in → renders
<App /> untouched.
Small non-invasive hooks into the existing shell
src/main.tsx wraps <App /> in <AuthProvider><AuthGate>….
Navbar profile pill now shows the real user's initials/name/role and includes a rich profile menu (avatar card + email) with a working Sign out action.
Dashboard greeting personalises the first name (e.g., "Good morning, Ava") — no other feature changed.
Try it: use [EMAIL_ADDRESS_3]/demo1234` (or click Autofill), or register a new workspace — data persists across reloads, and Sign out returns you to the login screen.
Files built: src/auth/AuthContext.tsx, src/auth/AuthLayout.tsx, src/auth/Login.tsx, src/auth/Register.tsx, src/auth/AuthGate.tsx, src/main.tsx, src/components/Navbar.tsx, src/pages/Dashboard.tsx