## MODIFIED Requirements ### Requirement: Staff login The system SHALL let an active admin user log in through the admin portal with company code, username and password, or with username and password and no company for a super admin, and SHALL return the user's name, roles, company, menu and whether a password change is required. #### Scenario: Correct credentials - **GIVEN** an active admin user `sales1` of active company `ins` - **WHEN** they submit company `ins`, username `sales1` and their password on the login page - **THEN** they are signed in and land on the portal home - **AND** the sidebar shows only the menu entries their roles grant #### Scenario: Super admin - **GIVEN** the super admin `admin`, who belongs to no company - **WHEN** they submit username `admin` and their password with the company left empty - **THEN** they are signed in #### Scenario: Wrong password - **WHEN** a user submits a wrong password - **THEN** `/api/admin/auth/login` responds 401 - **AND** the login page shows an invalid-credentials message without saying whether the company or username exists #### Scenario: Deactivated user - **GIVEN** an admin user whose account is deactivated - **WHEN** they submit their correct password - **THEN** login is refused with a 401 and the page shows the same invalid-credentials message #### Scenario: Member account - **WHEN** a member (non-admin) account submits its correct credentials to the admin login - **THEN** login is refused with a 401 ### Requirement: Forgot password The system SHALL let a user request a temporary password by entering their company code, username and email on a public forgot-password page; a super admin leaves the company empty. The response SHALL be the same whether or not the details match an active admin user. #### Scenario: Matching username and email - **GIVEN** an active admin user `sales1` of company `ins` with email `sales1@example.com` - **WHEN** someone submits company `ins`, username `sales1` and `sales1@example.com` - **THEN** a temporary password is emailed to `sales1@example.com` - **AND** the user must change it at next login - **AND** the page shows "If the details match an account, we have emailed a temporary password." #### Scenario: Non-matching details - **WHEN** someone submits a company, username and email that do not match an active admin user - **THEN** no password changes and no email is sent - **AND** the page shows the same message as for a match