feat: Add login/logout audit logging (refs #10)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 4m42s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 38s
Deploy to Staging / Verify Staging (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 6s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped

Backend:
- Add login event logging to getUserStatus() controller method
- Create POST /auth/track-logout endpoint for logout tracking

Frontend:
- Create useLogout hook that wraps Auth0 logout with audit tracking
- Update all logout locations to use the new hook (SettingsPage,
  Layout, MobileSettingsScreen, useDeletion)

Login events are logged when the frontend calls /auth/user-status after
Auth0 callback. Logout events are logged via fire-and-forget call to
/auth/track-logout before Auth0 logout.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Eric Gullickson
2026-01-11 12:08:41 -06:00
parent cdfba3c1a8
commit fbde51b8fd
7 changed files with 121 additions and 13 deletions

View File

@@ -5,6 +5,7 @@
import React from 'react';
import { useAuth0 } from '@auth0/auth0-react';
import { Link, useLocation } from 'react-router-dom';
import { useLogout } from '../core/auth/useLogout';
import { Container, Paper, Typography, Box, IconButton, Avatar } from '@mui/material';
import HomeRoundedIcon from '@mui/icons-material/HomeRounded';
import DirectionsCarRoundedIcon from '@mui/icons-material/DirectionsCarRounded';
@@ -26,7 +27,8 @@ interface LayoutProps {
}
export const Layout: React.FC<LayoutProps> = ({ children, mobileMode = false }) => {
const { user, logout } = useAuth0();
const { user } = useAuth0();
const { logout } = useLogout();
const { sidebarOpen, toggleSidebar, setSidebarOpen } = useAppStore();
const location = useLocation();
@@ -222,7 +224,7 @@ export const Layout: React.FC<LayoutProps> = ({ children, mobileMode = false })
variant="secondary"
size="sm"
className="w-full"
onClick={() => logout({ logoutParams: { returnTo: window.location.origin } })}
onClick={() => logout()}
>
Sign Out
</Button>