docs(openspec): rework add-admin-temporary-password to the legacy admin-set password flow

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
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-11-30 10:34:58 +08:00
1 parent 7c0a34508e
commit b49c9f1bc3
4 files changed
+185 -98

No files matched your search

@@ -13,57 +13,81 @@ Design: `design.md`. All tasks run serially: each builds on the one before.
Then show by reading the code that no `java.util.Random` remains in that method.
- Scope: `solvway-core-libs/src/**/ValidateUtil*`
- Verify: `mvn -T 1C -B -q -pl solvway-core-libs verify`.
- Verify: `mvn -T 1C -B -q -pl solvway-core-libs verify`
- [ ] 1.2 Issue a temporary password (design decisions 2 and 3).
- services-system: `POST /user/issueAdminTempPassword`.
- mobile-api: `POST /api/admin/users/{id}/temporary-password` and `AdminUserService.issueTemporaryPassword`.
- [ ] 1.2 services-system endpoints (design decision 2): `/user/validatePasswordFromRulesForAdmin` and `/user/setAdminPassword`.
Tests first:
- **services-system:**
- an enabled type-A user gets a 12-character password;
- the stored value is the bcrypt of that password, with `login = N`;
- a disabled, unknown or non-admin user gets no password, and nothing is saved;
- no email is sent.
- **mobile-api:**
- success returns the password with `Cache-Control: no-store`;
- validate returns the failing `ADMIN_PWD_FORMAT` rules, and an empty list for a passing password;
- set stores a bcrypt hash that matches the password, with `login = N`, for an enabled type-A user;
- set returns 0 and saves nothing for a disabled, unknown or non-admin user, or a password that fails the rules;
- no email is sent.
- Scope: `solvway-services-system/src/**` (user controller, service and tests)
- Verify: `mvn -T 1C -B -q -pl solvway-services-system -am verify`
- [ ] 1.3 mobile-api create and set password (design decisions 3 and 4).
Tests first:
- **create:**
- missing password gives 400 `REQUIRED_FIELD`;
- a mismatch gives 400 `PASSWORD_MISMATCH`;
- a rules failure gives 400 `PASSWORD_POLICY`;
- in all three cases no user is saved;
- success saves the user, calls `setAdminPassword` and sends no email;
- `setAdminPassword` returning 0 gives 500 `SAVE_FAILED`.
- **`POST /api/admin/users/{id}/password`:**
- success gives 204;
- own account gives 400 `SELF_NOT_ALLOWED`;
- a super admin target with a non-super caller gives 403;
- a disabled target gives 409 `USER_DISABLED`;
- an unknown target gives 404;
- a mismatch gives `PASSWORD_MISMATCH`, and a rules failure gives `PASSWORD_POLICY`;
- without `BO_USERS` the call is refused;
- the audit log line does not contain the password.
Live check through the gateway: set a temporary password for a made-up local user. Sign in with it, and get 403 `PASSWORD_RESET_REQUIRED`. Complete first-login and confirm the old password fails.
- Scope: `solvway-services-system/src/**` (user controller/service and tests), `solvway-mobile-api/src/**` (admin user files and tests)
- Verify: `mvn -T 1C -B -q -pl solvway-services-system,solvway-mobile-api -am verify`.
Live check through the gateway, on a made-up local user:
- create the user with a password;
- sign in with it and get 403 `PASSWORD_RESET_REQUIRED`;
- complete first-login;
- set a temporary password;
- check the old password now fails.
- Scope: `solvway-mobile-api/src/**` (admin user files, `AdminUserRequest` and tests)
- Verify: `mvn -T 1C -B -q -pl solvway-services-system,solvway-mobile-api -am verify`
## 2. Portal
- [ ] 2.1 "Set temporary password" on `/users/[id]` (design decision 4): a proxy route, a service function, the confirmation, the show-once dialog with copy, and i18n keys.
- [ ] 2.1 Password fields on `/users/new` and "Set temporary password" on `/users/[id]` (design decision 5): a proxy route, a service function and i18n keys.
Tests first:
- the button calls the service after confirmation;
- the dialog shows the returned password and a copy button;
- closing the dialog clears it, and it is not shown again on reload;
- each refusal code shows its message;
- the proxy route forwards `no-store`.
- Scope: `solvway-admin-portal/app/users/[id]/**`, `solvway-admin-portal/app/api/users/**`, `solvway-admin-portal/app/lib/**`
- Verify: `cd solvway-admin-portal && npx vitest run && npx tsc --noEmit && npm run lint && npm run build`.
- **create:**
- the form sends `password` and `confirmPassword`;
- a mismatch is caught before submitting;
- `PASSWORD_POLICY` shows its message.
- **edit:**
- the set-password form calls the service;
- success clears both fields and shows the confirmation;
- each refusal code shows its message;
- the form is hidden on the caller's own account.
- Scope: `solvway-admin-portal/app/users/**`, `solvway-admin-portal/app/api/users/**`, `solvway-admin-portal/app/lib/**`, i18n files
- Verify: `cd solvway-admin-portal && npx vitest run && npx tsc --noEmit && npm run lint && npm run build`
## 3. Check and docs
- [ ] 3.1 Browser check and handover.
- **Playwright on the local stack, as admin:**
- create a made-up user;
- set a temporary password;
- copy it;
- create a made-up user with a password;
- sign in as that user in a second session and get sent to the password change;
- change the password and reach the app;
- check the old temporary password now fails.
- **Refusals:** the admin's own account, and a deactivated user, each show their message.
- **Phone width:** check the dialog at 360px.
- **Docs:** update `docs/deployment.md` sections 2 (step 6) and 10 to say staff can be onboarded without email.
- back as admin, set a temporary password for that user;
- sign in with it and get sent to the password change again;
- check the old password fails.
- **Refusals, each with its message shown:**
- a weak password on create;
- a mismatch on create;
- a deactivated user;
- **Own account:** the set-password form is not shown.
- **Phone width:** check both forms at 360px.
- **Docs:** update `docs/deployment.md` sections 2 (step 6) and 10.
- Scope: `docs/deployment.md`
- Verify: screenshots, and the steps above observed.