Add password resets, change password, sign-out, a Branches link and moving staff #8

Merged
denis_ireri merged 1 commits from fix/account-and-navigation-gaps into main 2026-10-13 11:04:48 +00:00
Contributor

Fixes the account and navigation gaps found while writing the user manual.

What changes

  • Forgotten passwords
    • Staff page: Reset password creates a one-time reset link (owners: anyone in the business except themselves; managers: their own branch's cashiers). It expires after 24 hours; the old password keeps working until the link is used, and using it signs the account out on every device.
    • Reset and invite links share the invite page, which now says which it is. User.invitePurpose tells them apart, so a reset never shows as "Invite pending" (existing rows with no value are treated as invites).
    • An owner who forgets their password gets a link from the platform operator: Platform console → Owner password link (POST /api/platform/businesses/:id/owner-reset).
    • "Forgot password?" on the sign-in page explains who to ask.
  • Change password (POST /api/auth/password): any signed-in user, from the dashboard, the till or the platform console. Needs the current password; other devices are signed out, this one stays signed in.
  • Sign out on the dashboard and the platform console (the till already had it), through one shared helper that also clears the till's cached session.
  • Branches link on the owner's dashboard; the page was only reachable by typing its address.
  • Move staff between branches: owners get a Move to… menu on Staff for managers and cashiers. The person is signed out and signs in again. A moved manager stops being the old branch's manager and becomes the new branch's if it has none.

Testing

  • npm test: 91 tests pass, 8 new in tests/account.test.ts:
    • a manager resets a cashier's password; the old one works until the link is used; using it signs out every device;
    • a reset is not shown as a pending invite; a reset link expires after 24 hours;
    • managers only reset their own cashiers; nobody resets themselves;
    • the platform operator can give an owner a reset link; an owner cannot;
    • change password needs the current one and signs out other devices only;
    • moving a manager updates both branches' manager and signs them out; only the owner can move people, and only to an active branch.
  • Production build passes.
  • Browser (local test copy): Branches link and account links on the dashboard; Reset password and Move to… on Staff; the reset page; Change password; Sign out lands on the sign-in page with the session gone.

No migration or deploy step beyond the usual /opt/aquaflow/deploy.sh.

🤖 Generated with Claude Code

Fixes the account and navigation gaps found while writing the user manual. ## What changes - **Forgotten passwords** - Staff page: **Reset password** creates a one-time reset link (owners: anyone in the business except themselves; managers: their own branch's cashiers). It expires after 24 hours; the old password keeps working until the link is used, and using it signs the account out on every device. - Reset and invite links share the invite page, which now says which it is. `User.invitePurpose` tells them apart, so a reset never shows as "Invite pending" (existing rows with no value are treated as invites). - An owner who forgets their password gets a link from the platform operator: Platform console → **Owner password link** (`POST /api/platform/businesses/:id/owner-reset`). - "Forgot password?" on the sign-in page explains who to ask. - **Change password** (`POST /api/auth/password`): any signed-in user, from the dashboard, the till or the platform console. Needs the current password; other devices are signed out, this one stays signed in. - **Sign out** on the dashboard and the platform console (the till already had it), through one shared helper that also clears the till's cached session. - **Branches** link on the owner's dashboard; the page was only reachable by typing its address. - **Move staff between branches**: owners get a **Move to…** menu on Staff for managers and cashiers. The person is signed out and signs in again. A moved manager stops being the old branch's manager and becomes the new branch's if it has none. ## Testing - `npm test`: 91 tests pass, 8 new in `tests/account.test.ts`: - a manager resets a cashier's password; the old one works until the link is used; using it signs out every device; - a reset is not shown as a pending invite; a reset link expires after 24 hours; - managers only reset their own cashiers; nobody resets themselves; - the platform operator can give an owner a reset link; an owner cannot; - change password needs the current one and signs out other devices only; - moving a manager updates both branches' manager and signs them out; only the owner can move people, and only to an active branch. - Production build passes. - Browser (local test copy): Branches link and account links on the dashboard; Reset password and Move to… on Staff; the reset page; Change password; Sign out lands on the sign-in page with the session gone. No migration or deploy step beyond the usual `/opt/aquaflow/deploy.sh`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
denis_ireri added 1 commit 2026-10-13 11:03:46 +00:00
Gaps found while writing the user manual:

- Forgotten passwords: owners and managers can create a one-time
  password reset link from Staff (managers for their own cashiers). It
  expires after 24 hours; the old password works until it is used, and
  using it signs the account out everywhere. Reset and invite links share
  the invite page, which now says which it is. An owner who forgets their
  password gets a link from the platform operator (Platform console,
  "Owner password link"). The login page's "Forgot password?" explains
  this.
- Change password: any signed-in user, from the dashboard, the till or
  the platform console. Needs the current password; other devices are
  signed out.
- Sign out on the dashboard and the platform console (the till already
  had it), through one shared helper that also clears the till's cached
  session.
- A Branches link on the owner's dashboard; the page was only reachable
  by typing its address.
- Owners can move a manager or cashier to another branch from Staff. A
  moved manager stops being the old branch's manager and becomes the new
  branch's if it has none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
denis_ireri merged commit 5b7a2b847f into main 2026-10-13 11:04:48 +00:00
denis_ireri deleted branch fix/account-and-navigation-gaps 2026-10-13 11:04:53 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Ezekiel_Nyangweso/ERP#8