Admin
User Management
| Path | /user-management |
|---|---|
| Status | live |
| Drill-down pages | — |
| Pop-ups | Create, Edit, Reset Password, Delete confirm, Resend invite, Activate/Deactivate |
| Tabs | — |
| API routes | /api/user-management/users/api/user-management/users/:id/api/user-management/users/:id/resend-invite |
Business rules
Data comes from: dh_users (one row per login). Access: admins only (role admin or the admin access key), checked on the server. The user-management page key alone is not enough: whoever manages logins can make themselves admin.
How it works:
- Roles: User, Staff (portal only: staff schedule, time off, my account), Admin (everything). Status: active, inactive, invited (set-up link sent, no password yet). The database refuses any other value (migration 173).
- Create User never sets a password: the login is invited and emailed its one-time set-up link (template
staff_pulse_invite). Resend invite sends a new link and cancels the old one (only while invited). - Access: page keys, one row per login per key in
dh_user_access(migration 174), checked on save (known-looking keys, no duplicates). Read on every request, so a change applies at once.dh_users.accessis only a copy kept in step by the database until it is removed. - Guards: you cannot remove your own admin, deactivate yourself or delete yourself; the last active admin cannot lose admin or be deleted; an invited login cannot be activated (use Resend invite).
- Reset Password: at least 6 characters (same rule as set-up); on staging it also clears a sign-in lockout. It signs that login out everywhere. You can't reset your own password here; use My Portal → Change Password. Deactivating a login also signs it out everywhere.
- Email is stored lower-case and is unique. Every create, change, invite and delete is in the Audit Log (no passwords).
Database tables & columns
| Table | Columns used |
|---|---|
dh_user_access | access_key, position, user_id |
dh_users | access, email, id, name, password_hash, role, status |
email_sends | app, error, lang, provider, recipients, ref, sent_by, status, subject, subject_encrypted, template_key, to_email, to_email_encrypted, to_email_hash |
email_templates | active, bcc_emails, body_en, body_es, from_email, key, reply_to, subject_en, subject_es, to_emails |
staff_invites | created_by, expires_at, staff_id, token_hash, user_id |
File structure
Its own files
- apps/
- web/
- src/
- features/
- user-management/
- pages/
- UserManagementPage.tsx
- index.ts
- pages/
- user-management/
- features/
- src/
- worker/
- src/
- features/
- user-management/
- __tests__/
- service.test.ts
- index.ts
- queries.ts
- routes.ts
- service.ts
- __tests__/
- user-management/
- features/
- src/
- web/
Shared code it uses (followed through its imports and the helpers its API calls; sign-in/access plumbing and UI primitives left out)
- apps/
- web/
- src/
- components/
- reports/
- DentrixSourceNote.tsx
- HowItWorksNote.tsx
- ReportHeader.tsx
- users/
- access.tsx
- reports/
- hooks/
- useApi.ts
- services/
- api.ts
- components/
- src/
- worker/
- src/
- db/
- index.ts
- services/
- email-templates.ts
- staff-onboarding.ts
- user-access.ts
- utils/
- email.ts
- password.ts
- db/
- src/
- web/