Repository navigation
Feature/66 account management - #94
Merged
Merged
Conversation
…es with a permission
…loyee accounts with their history
…he active-account rule
15 tasks done
…deactivation and reactivation
… changes migration after develop's
… changes migration after develop's
anis022
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #66
Overview
api/accounts(all routes Admin only,ManageAccounts): list, roles, get, history, add, edit, change role, deactivate, reactivateuser_account_changes: every change with the admin who made it and the before and after values (migrationAddUserAccountChanges, SQL script0012)usersuses PostgreSQL'sxmincolumn as a version, so a second save on a changed account returns 409 instead of overwriting it (no new column)FOR UPDATE, so two admins cannot deactivate each other at the same time), and an admin cannot change their own role or remove their own access/api/menow returns the employee's app roleusers-roles.md(history table, admin handover) androles-permissions.mdTesting
Automated tests (Docker must be running): all 745 pass with
dotnet test.ActiveAccountTests: a deactivated or never-added account is refused on every route, with the same answer, even with a valid tokenAuthenticationTests:/api/mereturns the role, and a role change takes effect on the next requestAccountServiceTests: add, unique email regardless of case, edit with version check (also when another admin saves in between), role, deactivate and reactivate, history, last admin (also two admins at the same time), own accountAccountEndpointTests: 401, 403 for every non-admin role on every route, 201 and the new employee can then sign in, 400, 404, 409, data created by an employee stays attributed to them after deactivation and reactivationManual test in the app with the test account: add, edit, change role, remove and give back access, own account buttons disabled, "no access" message after deactivating my own account in the local database.
Screenshots / Screencasts
All screenshots of the manual test (11)
1. Home page: signed in as an Admin, with the Accounts button

2. Accounts screen: only the first admin

3. Employee added (Supply, not signed in yet)

4. Confirmation before changing the role

5. Role changed to Supply Director

6. Confirmation before removing access

7. Access removed: the account is kept and marked Deactivated

8. Confirmation before giving the access back

9. Access given back

10. Own account: role and access buttons disabled

11. Deactivated account: neutral message at sign-in

Checklist
Notes
Program.cs). Before, routes without a permission (GET catalog items, prices, BC mappings,/api/me) accepted any valid Microsoft token, even for a deactivated or never-added account. For new API tests: create an active user first (ReplaceUsersWithAsyncorSignInAsAsync), otherwise the route returns 403. I adjustedAuthenticationTests(now uses a real database) andCatalogItemPricesEndpointTests(adds an active user).users-roles.md).user_account_changeslinks tousers, so test helpers that delete all users need the history emptied first (same as the mapping tables in [Issue]: BC-to-grid mapping: storage, confirmation and reuse #73).