Files
co-lite/openspec/changes/add-admin-temporary-password/tasks.md
T

73 lines
3.4 KiB
Markdown

# Tasks
Design: `design.md`. All tasks run serially: each builds on the one before.
## 1. Backend
- [ ] 1.1 Secure generator (design decision 1). `ValidateUtil.getRandomPasswordString` draws from a static `SecureRandom` with the same alphabet.
Tests first:
- the length matches the argument;
- every character is in the alphabet;
- 1,000 calls of length 12 are all distinct.
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`.
- [ ] 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`.
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`;
- 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;
- 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`.
## 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.
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`.
## 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;
- 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.
- Scope: `docs/deployment.md`
- Verify: screenshots, and the steps above observed.
## Workflow follow-up
- Whole-branch review, push, PR to main and merge, then archive on its own branch.