feat: admin-set passwords so staff can sign in without email #15

Merged
ngqile merged 6 commits from add-admin-temporary-password into main 2026-11-30 03:27:56 +00:00
Owner

OpenSpec change add-admin-temporary-password.

Why

No email provider is configured for go-live (2027-01-15). Staff could only get a password by email, so only the first admin could sign in. This follows the legacy backoffice flow: the admin types the password, and the user must change it at first sign-in.

What

  • Create user: Password + Confirm password. The password must match and pass the admin password rules. The user is saved with login = N. No email is sent.
  • Set temporary password on the user edit page (POST /api/admin/users/{id}/password). It is refused for the caller's own account (400), a disabled user (409) and a super admin when the caller is not one (403). The old password stops working and the user must change it at next sign-in.
  • services-system: /user/validatePasswordFromRulesForAdmin and /user/setAdminPassword (bcrypt, login = N, never emailed or logged).
  • ValidateUtil.getRandomPasswordString uses SecureRandom (emailed admin reset and forgot-password).
  • docs/deployment.md: staff onboarding without email (sections 2 and 10); appkeys.json must keep mobile-api as the only client.

Verification

  • mvn -T 1C -pl solvway-services-system,solvway-mobile-api -am verify: green (mobile-api 491 tests).
  • Portal: vitest 1166 passed, tsc clean, lint 0 errors, next build OK.
  • Live through the gateway: create, then 403 PASSWORD_RESET_REQUIRED, then first-login. Set temporary password: the old password is rejected and the change is forced again. The refusals (own account, disabled user, mismatch, policy) and the audit line (no password) were checked.
  • Playwright on the local stack:
    • create with mismatch, weak and valid passwords;
    • forced change as the new user;
    • set temporary password, with the policy error and the success banner;
    • old password shows "Invalid username or password";
    • the disabled-user refusal is shown;
    • the button is hidden on the admin's own account;
    • 360px screenshots.
  • Per-task Review Gates and a whole-branch review passed. Review findings were fixed in d2560c6.

Follow-ups (not in this PR)

  • The legacy /user/resetPassword sets the password to the bcrypt of the username, keyed only by email. It should be removed or locked down.
  • Member and stockist generators (PubSubListener, getRandomNumericString) still use java.util.Random.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM

OpenSpec change `add-admin-temporary-password`. ## Why No email provider is configured for go-live (2027-01-15). Staff could only get a password by email, so only the first admin could sign in. This follows the legacy backoffice flow: the admin types the password, and the user must change it at first sign-in. ## What - **Create user**: Password + Confirm password. The password must match and pass the admin password rules. The user is saved with `login = N`. No email is sent. - **Set temporary password** on the user edit page (`POST /api/admin/users/{id}/password`). It is refused for the caller's own account (400), a disabled user (409) and a super admin when the caller is not one (403). The old password stops working and the user must change it at next sign-in. - services-system: `/user/validatePasswordFromRulesForAdmin` and `/user/setAdminPassword` (bcrypt, `login = N`, never emailed or logged). - `ValidateUtil.getRandomPasswordString` uses `SecureRandom` (emailed admin reset and forgot-password). - `docs/deployment.md`: staff onboarding without email (sections 2 and 10); `appkeys.json` must keep mobile-api as the only client. ## Verification - `mvn -T 1C -pl solvway-services-system,solvway-mobile-api -am verify`: green (mobile-api 491 tests). - Portal: vitest 1166 passed, `tsc` clean, lint 0 errors, `next build` OK. - Live through the gateway: create, then 403 `PASSWORD_RESET_REQUIRED`, then first-login. Set temporary password: the old password is rejected and the change is forced again. The refusals (own account, disabled user, mismatch, policy) and the audit line (no password) were checked. - Playwright on the local stack: - create with mismatch, weak and valid passwords; - forced change as the new user; - set temporary password, with the policy error and the success banner; - old password shows "Invalid username or password"; - the disabled-user refusal is shown; - the button is hidden on the admin's own account; - 360px screenshots. - Per-task Review Gates and a whole-branch review passed. Review findings were fixed in d2560c6. ## Follow-ups (not in this PR) - The legacy `/user/resetPassword` sets the password to the bcrypt of the username, keyed only by email. It should be removed or locked down. - Member and stockist generators (`PubSubListener`, `getRandomNumericString`) still use `java.util.Random`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
ngqile added 6 commits 2026-11-30 03:27:52 +00:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
The admin types the initial password on create and a temporary password on
edit; the user is saved with login = N and must change it at first sign-in.
No email is needed to onboard staff.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Creating a user takes the first password from the admin, and a new
POST /api/admin/users/{id}/password lets an admin set a temporary password
for another active user. Both store the bcrypt hash with login = N, so the
user must choose their own password at the next sign-in. No email is sent.
The password must match its confirmation and pass the admin password rules.
The emailed-password generator now draws from SecureRandom.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
Create shows a link back to Users when the user was saved but the password
was not stored. The spec's secure-generator rule now names admin temporary
passwords only, and the reset requirement no longer implies the emailed reset
refuses the caller's own account. The design and handover note that mobile-api
must stay the only gateway client allowed to reach /user/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
ngqile merged commit 58ed85bdc9 into main 2026-11-30 03:27:56 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ngqile/co-lite#15