Enhanced audit log for user profiles #154
Reference in New Issue
Block a user
Delete Branch "Enhanced-Audit-log-for-user-Profiles"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
logActionserver 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]logActioninto 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:
AccountLogcomponent 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, apps/hub/app/(app)/admin/user/[id]/page.tsxL2-R2, apps/hub/app/(app)/admin/user/[id]/page.tsxR12-R14, apps/hub/app/(app)/admin/user/[id]/page.tsxR41-R60, apps/hub/app/(app)/admin/user/[id]/page.tsxR179-R184)isDeleted: trueinstead of removing the user record, and ensured authentication only considers non-deleted users. (apps/hub/app/(app)/admin/user/action.tsL61-R67, apps/hub/app/api/auth/[...nextauth]/auth.tsR26, apps/hub/app/api/auth/[...nextauth]/auth.tsR91)Paginated Table and UI Improvements:
PaginatedTablecomponent to support an additionalrightOfPaginationprop for custom controls, and made table and pagination controls more compact and consistent in size. [1] [2] [3] [4] [5] [6]Other Notable Changes:
These changes together significantly improve the auditability, security, and usability of the admin interface and user management features.