Skip to content

Improve user management: remove audit log, fix bugs, add sessions#20

Merged
antosubash merged 5 commits intomainfrom
claude/improve-user-management-3RxvM
Mar 30, 2026
Merged

Improve user management: remove audit log, fix bugs, add sessions#20
antosubash merged 5 commits intomainfrom
claude/improve-user-management-3RxvM

Conversation

@antosubash
Copy link
Copy Markdown
Owner

@antosubash antosubash commented Mar 28, 2026

Summary

  • Remove custom audit logging from Admin module — the dedicated AuditLogs module handles this automatically via HTTP middleware and entity change tracking
  • Fix AdminUserDto missing fields (twoFactorEnabled, accessFailedCount, lastLoginAt) that the frontend rendered as undefined
  • Fix password match validation on Create User form
  • Prevent self-lockout — admins can no longer deactivate or lock their own account (server guard + UI)
  • Surface validation errors on create user form via onError callback
  • Fix N+1 query in GetUsersPagedAsync by batch-loading roles with a single join
  • Upgrade Users list to DataGridPage with status and role filter dropdowns using design system Select components
  • Parallelize DB calls in UsersEndpoint and UsersEditEndpoint via Task.WhenAll
  • Collapse sequential Identity writes (lock/unlock/deactivate/reactivate) into single UpdateAsync calls
  • Add active sessions tab — shows OpenIddict access/refresh tokens per user with individual and bulk revocation

Test plan

  • Verify users list loads with status and role filters working
  • Create a user — confirm password mismatch shows error, duplicate email shows error
  • Edit own user — confirm deactivate/lock buttons are hidden with explanation
  • Edit another user — confirm deactivate/lock/unlock work
  • Check Sessions tab shows active tokens and revoke works
  • Verify no audit log references remain (activity tab removed)
  • Run dotnet test — all tests pass
  • Run npm run check — lint passes

@antosubash antosubash force-pushed the claude/improve-user-management-3RxvM branch 2 times, most recently from c2ffb7a to 649bacd Compare March 28, 2026 12:48
@antosubash antosubash changed the title Improve user management: remove custom audit log, fix bugs, enhance UX Improve user management: remove audit log, fix bugs, add sessions Mar 28, 2026
@antosubash antosubash force-pushed the claude/improve-user-management-3RxvM branch 2 times, most recently from 20cd3e8 to 6b99081 Compare March 28, 2026 15:36
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 28, 2026

Deploying simplemodule with  Cloudflare Pages  Cloudflare Pages

Latest commit: bb8d7bf
Status: ✅  Deploy successful!
Preview URL: https://dce54d48.simplemodule.pages.dev
Branch Preview URL: https://claude-fix-pr20-errors-4ttip.simplemodule.pages.dev

View logs

@antosubash antosubash force-pushed the claude/improve-user-management-3RxvM branch 2 times, most recently from d3fa853 to 83bb614 Compare March 28, 2026 22:19
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 28, 2026

Deploying simplemodule-website with  Cloudflare Pages  Cloudflare Pages

Latest commit: 04c477a
Status: ✅  Deploy successful!
Preview URL: https://64299156.simplemodule-website.pages.dev
Branch Preview URL: https://claude-improve-user-manageme.simplemodule-website.pages.dev

View logs

Remove the Admin module's custom audit logging (AuditService, AuditLogEntry,
ActivityTimeline, activity tab) since the dedicated AuditLogs module now handles
this automatically via HTTP middleware and entity change tracking.

Bug fixes:
- Add missing fields to AdminUserDto (twoFactorEnabled, accessFailedCount,
  lastLoginAt) that the frontend was rendering as undefined
- Add password match validation on UsersCreate form
- Prevent admins from locking/deactivating their own account (server + UI)
- Surface validation errors on create user form via onError callback

Performance:
- Fix N+1 query in GetUsersPagedAsync by batch-loading roles with a single
  join query instead of per-user GetRolesAsync calls

UX improvements:
- Upgrade Users list to DataGridPage component (consistent with Roles page)
- Add status filter (active/locked/deactivated) and role filter dropdowns
- Show "You" badge and created date on user edit page
- Show locked badge on user header when applicable
…ndancy

- Replace native <select> elements with @simplemodule/ui Select components
  for visual consistency with the rest of the admin UI
- Remove redundant goToPage function (navigate already handles it)
- Remove redundant userRoles prop (derivable from user.roles)
- Parallelize independent DB calls in UsersEndpoint and UsersEditEndpoint
  using Task.WhenAll for lower latency on page loads
- Collapse sequential Identity writes (Lock/Unlock/Deactivate/Reactivate)
  into single UpdateAsync calls to reduce round-trips
Add a Sessions tab to the user edit page that shows active OpenIddict tokens
(access and refresh) for the user, with ability to revoke individual sessions
or all sessions at once.

Architecture:
- IOpenIddictSessionContracts + UserSessionDto in OpenIddict.Contracts
- OpenIddictSessionService queries tokens via IOpenIddictTokenManager
- AdminSessionsEndpoint provides DELETE routes for revocation
- UsersEditEndpoint fetches sessions in parallel with other data

The session service filters to valid, non-expired tokens, caches application
name lookups, and uses OpenIddict's TryRevokeAsync for proper revocation.
@antosubash antosubash force-pushed the claude/improve-user-management-3RxvM branch from 83bb614 to 3ea7826 Compare March 30, 2026 12:56
AdminDbContext was deleted when removing the custom audit log from the
Admin module, but the test fixture still referenced it for SQLite
replacement and database initialization.
@antosubash antosubash force-pushed the claude/improve-user-management-3RxvM branch from 3ea7826 to e5fa4e5 Compare March 30, 2026 12:57
@antosubash antosubash merged commit 0eba216 into main Mar 30, 2026
3 checks passed
@antosubash antosubash deleted the claude/improve-user-management-3RxvM branch April 1, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant