Enhanced audit log for user profiles #154

Merged
PxlLoewe merged 6 commits from Enhanced-Audit-log-for-user-Profiles into staging 2026-01-30 16:01:50 +00:00
PxlLoewe commented 2026-01-30 16:01:23 +00:00 (Migrated from github.com)

This pull request introduces a comprehensive user account logging and auditing system, along with UI improvements and soft-deletion for users. The main focus is on tracking user actions (such as login, registration, and profile changes), detecting potential duplicate accounts, and surfacing relevant logs in the admin interface. Additionally, there are several UI tweaks for consistency and usability.

Account Logging and Auditing:

  • Added a new logAction server utility that logs user actions (LOGIN, REGISTER, PROFILE_CHANGE, etc.) to the database, capturing metadata such as IP, device, and browser. It detects possible duplicate accounts based on shared IP/device and automatically creates a report and Discord embed if suspicious activity is found. [1] [2]
  • Integrated logAction into the login, registration, and profile update flows to ensure key user actions are tracked and auditable. [1] [2] [3] [4] [5] [6]

Admin User Page Enhancements:

Paginated Table and UI Improvements:

  • Enhanced the PaginatedTable component to support an additional rightOfPagination prop for custom controls, and made table and pagination controls more compact and consistent in size. [1] [2] [3] [4] [5] [6]
  • Standardized icon sizing and ordering in admin report columns for improved visual consistency. [1] [2] [3]

Other Notable Changes:

  • Ensured events are listed in descending order by ID for more intuitive viewing. [1] [2]
  • Minor code cleanup and utility additions.

These changes together significantly improve the auditability, security, and usability of the admin interface and user management features.

This pull request introduces a comprehensive user account logging and auditing system, along with UI improvements and soft-deletion for users. The main focus is on tracking user actions (such as login, registration, and profile changes), detecting potential duplicate accounts, and surfacing relevant logs in the admin interface. Additionally, there are several UI tweaks for consistency and usability. **Account Logging and Auditing:** * Added a new `logAction` server utility that logs user actions (LOGIN, REGISTER, PROFILE_CHANGE, etc.) to the database, capturing metadata such as IP, device, and browser. It detects possible duplicate accounts based on shared IP/device and automatically creates a report and Discord embed if suspicious activity is found. [[1]](diffhunk://#diff-5f03c253974626d8d2292ae270642c3ac959080d8102cf560a6c47f3d6ac4095R1-R87) [[2]](diffhunk://#diff-aae80b58efd51f9411918e615129b12fbe1c7759b10e8ae554fbe7247ee6ecdcR41-R50) * Integrated `logAction` into the login, registration, and profile update flows to ensure key user actions are tracked and auditable. [[1]](diffhunk://#diff-44a1ce718f702f068186d6107271ec50e1f36696d3c414748184bf4c7b1197e1R12) [[2]](diffhunk://#diff-44a1ce718f702f068186d6107271ec50e1f36696d3c414748184bf4c7b1197e1R50-R53) [[3]](diffhunk://#diff-b8f530c3bd82aa883d07b48eecb0ecf6ce95277ef4851120ff64c531fbc38861R12) [[4]](diffhunk://#diff-b8f530c3bd82aa883d07b48eecb0ecf6ce95277ef4851120ff64c531fbc38861R97-R99) [[5]](diffhunk://#diff-8080671844b01be53ecbf91732e73ae874ad67abe4d3a48bc5fa51f3d577a0f4R26) [[6]](diffhunk://#diff-8080671844b01be53ecbf91732e73ae874ad67abe4d3a48bc5fa51f3d577a0f4R105-R126) **Admin User Page Enhancements:** * Added an `AccountLog` component to the admin user page, displaying a paginated, filterable table of logs related to the user and any logs from the same IP (potentially highlighting suspicious activity). Includes a toggle to show only important entries. ([apps/hub/app/(app)/admin/user/[id]/_components/AccountLog.tsxR1-R137](diffhunk://#diff-42a5c77e7a643d5b4a48660acf2686718f8a78b508ceac64822d51cceb52f3efR1-R137), [apps/hub/app/(app)/admin/user/[id]/page.tsxL2-R2](diffhunk://#diff-75cf4449e2b5268cfa88e79f6e04bd802eab1b649e2a15703af97728dea0463fL2-R2), [apps/hub/app/(app)/admin/user/[id]/page.tsxR12-R14](diffhunk://#diff-75cf4449e2b5268cfa88e79f6e04bd802eab1b649e2a15703af97728dea0463fR12-R14), [apps/hub/app/(app)/admin/user/[id]/page.tsxR41-R60](diffhunk://#diff-75cf4449e2b5268cfa88e79f6e04bd802eab1b649e2a15703af97728dea0463fR41-R60), [apps/hub/app/(app)/admin/user/[id]/page.tsxR179-R184](diffhunk://#diff-75cf4449e2b5268cfa88e79f6e04bd802eab1b649e2a15703af97728dea0463fR179-R184)) * Updated the user deletion logic to perform a soft delete by setting `isDeleted: true` instead of removing the user record, and ensured authentication only considers non-deleted users. ([apps/hub/app/(app)/admin/user/action.tsL61-R67](diffhunk://#diff-147cdbfbb6f264bbbb8d57b47f89417d17dc84d9d04590581ba96905acb60e34L61-R67), [apps/hub/app/api/auth/[...nextauth]/auth.tsR26](diffhunk://#diff-08bdc46eb88d1e4393d1de93f6b765bffd8fd07ada51115606a60011d87fb532R26), [apps/hub/app/api/auth/[...nextauth]/auth.tsR91](diffhunk://#diff-08bdc46eb88d1e4393d1de93f6b765bffd8fd07ada51115606a60011d87fb532R91)) **Paginated Table and UI Improvements:** * Enhanced the `PaginatedTable` component to support an additional `rightOfPagination` prop for custom controls, and made table and pagination controls more compact and consistent in size. [[1]](diffhunk://#diff-f432e98972b2e8975f2c6b35a401e251dd98ecfb850127eafb9f74fea7243e94R24) [[2]](diffhunk://#diff-f432e98972b2e8975f2c6b35a401e251dd98ecfb850127eafb9f74fea7243e94R41) [[3]](diffhunk://#diff-f432e98972b2e8975f2c6b35a401e251dd98ecfb850127eafb9f74fea7243e94L162-L165) [[4]](diffhunk://#diff-d92cb9af43d556b5cbab966e3a2adf9470fb614387a156f7c3053cf2b705ee94L98-R98) [[5]](diffhunk://#diff-d92cb9af43d556b5cbab966e3a2adf9470fb614387a156f7c3053cf2b705ee94L125-R133) [[6]](diffhunk://#diff-d92cb9af43d556b5cbab966e3a2adf9470fb614387a156f7c3053cf2b705ee94L140-R148) * Standardized icon sizing and ordering in admin report columns for improved visual consistency. [[1]](diffhunk://#diff-6fc1ad256cb88e99e9abbff6a3ff7991171f9d1d068f332ff1a99a6f8e75fd47L15-R17) [[2]](diffhunk://#diff-6fc1ad256cb88e99e9abbff6a3ff7991171f9d1d068f332ff1a99a6f8e75fd47L34-R40) [[3]](diffhunk://#diff-6fc1ad256cb88e99e9abbff6a3ff7991171f9d1d068f332ff1a99a6f8e75fd47L65-R65) **Other Notable Changes:** * Ensured events are listed in descending order by ID for more intuitive viewing. [[1]](diffhunk://#diff-fc5f3cd0ca4b0507e9b624850ceaa31c93d09d02ab6205c849300fcdf6873811R13-R15) [[2]](diffhunk://#diff-fc5f3cd0ca4b0507e9b624850ceaa31c93d09d02ab6205c849300fcdf6873811L23-L26) * Minor code cleanup and utility additions. These changes together significantly improve the auditability, security, and usability of the admin interface and user management features.
Sign in to join this conversation.