Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
4.1 KiB
MODIFIED Requirements
Requirement: Create user
The system SHALL let an admin with BO_USERS create an admin user with name, username, email, one or more roles, and an initial password with its confirmation. Username and email SHALL be unique. The password SHALL match its confirmation and pass the admin password rules. The new user SHALL be saved with a pending password change, SHALL belong to the creating admin's company, and SHALL NOT be sent an email.
Scenario: New user
- WHEN an admin creates user
sales1with emailsales1@example.com, role Sales and a valid initial password - THEN the user is saved as active with a pending password change
- AND
sales1can sign in with that password and must choose a new password before anything else - AND no email is sent
- AND the user's company is the creating admin's company
Scenario: Duplicate username
- GIVEN a user
sales1exists - WHEN an admin creates another user with username
sales1 - THEN the save is refused and the form shows that the username is taken
Scenario: Weak or mismatched initial password
- WHEN an admin creates a user with a password that fails the admin password rules, or that does not match its confirmation
- THEN the save is refused with a message on the form
- AND no user is created
Requirement: Admin-triggered password reset
The system SHALL let an admin with BO_USERS give an active admin user a new password in one of two ways: an emailed reset, where the system emails a generated temporary password, or a temporary password the admin types with its confirmation. Either way the user's old password SHALL stop working, and the user SHALL be required to change the password at the next login. A typed password SHALL pass the admin password rules. No password SHALL be logged or returned in a response.
Scenario: Reset
- WHEN an admin resets
sales1's password by email - THEN
sales1's old password stops working - AND a temporary password is emailed to
sales1's email address
Scenario: Admin sets a temporary password
- GIVEN an active user
sales1 - WHEN an admin sets a temporary password for
sales1that passes the rules and matches its confirmation - THEN
sales1's old password stops working - AND
sales1can sign in with the temporary password and must choose a new password before anything else
Scenario: Weak or mismatched temporary password
- WHEN an admin sets a temporary password that fails the admin password rules, or that does not match its confirmation
- THEN the request is refused with a message
- AND
sales1's password is unchanged
Scenario: No direct password set
- WHEN an admin calls
POST /api/admin/users/{id}/changePassword - THEN the endpoint does not exist and no password changes
ADDED Requirements
Requirement: Temporary password refusals
The system SHALL refuse to set a temporary password for a disabled user, for the caller's own account, and for a super admin when the caller is not a super admin, and SHALL leave that user's password unchanged.
Scenario: Disabled user
- GIVEN user
sales2is deactivated - WHEN an admin sets a temporary password for
sales2 - THEN the request is refused and
sales2's password is unchanged
Scenario: Own account
- WHEN an admin sets a temporary password for their own account
- THEN the request is refused
Scenario: Super admin target
- GIVEN the caller is not a super admin
- WHEN they set a temporary password for a super admin
- THEN the request is refused and the super admin's password is unchanged
Requirement: Generated temporary passwords are unpredictable
Every temporary password the system generates for an admin user SHALL come from a cryptographically secure random source. This covers the emailed admin reset and admin forgot-password.
Scenario: Generated passwords do not repeat
- WHEN the system generates 1,000 temporary passwords of 12 characters
- THEN all of them are different
- AND every character comes from the generator's alphabet