Skip to content
SprecherEast
Issue 134

tech-debt: Accounts module: one getCurrentUser() over the Local API; sign-in as server actions

Back to our plan
Done
cmsauthtech-debtpriority: medium

Type

tech-debt

Summary

Create one place that answers "who is signed in and what may they do", so future features (resident accounts, comments, permissions) build on a single, tested foundation instead of each page doing it its own way.

Problem

Proposed fix

Create src/modules/accounts/:

  • data/: getCurrentUser() (cached per request, Local API).
  • use-cases/: requireUser() / requireRole(role), exported from server.ts.
  • actions.ts: sign in, sign out and change password as server actions that validate input and re-check the user.
  • Role checks and access functions stay shared in src/platform/payload/ (moved from src/access/), because every module uses them and platform/ imports no module (docs/architecture/README.md, rule 3). accounts owns the role field.
  • cms/: the Users collection.
  • ui/: login form, change-password form, the header's account menu state.

Acceptance criteria

  • Not done: No component or page calls /api/users/* directly.
  • Not done: Role checks exist once and are unit-tested; Payload access functions use them.
  • Not done: Login, logout, /account, change password and the header's signed-in state work as before (checked locally).
  • Not done: Error messages on sign-in stay generic (no account enumeration).

Depends on

#129 and #130. Before resident sign-up opens, also #140 (via #143) and #147. Step 9 of #127.

Area

auth, cms

Priority

medium


Generated by Claude Code, opens in a new tab

See it on GitHub, opens in a new tab