Files
motovaultpro/backend/src/features/auth/api/auth.routes.ts
Eric Gullickson fbde51b8fd
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
feat: Add login/logout audit logging (refs #10)
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>
2026-01-11 12:08:41 -06:00

58 lines
2.2 KiB
TypeScript

/**
* @ai-summary Fastify routes for auth API
* @ai-context Route definitions with Zod validation and authentication
*/
import { FastifyInstance, FastifyPluginOptions } from 'fastify';
import { FastifyPluginAsync } from 'fastify';
import { AuthController } from './auth.controller';
export const authRoutes: FastifyPluginAsync = async (
fastify: FastifyInstance,
_opts: FastifyPluginOptions
) => {
const authController = new AuthController();
// POST /api/auth/signup - Create new user (public, no JWT required)
fastify.post('/auth/signup', authController.signup.bind(authController));
// GET /api/auth/verify-status - Check verification status (requires JWT)
fastify.get('/auth/verify-status', {
preHandler: [fastify.authenticate],
handler: authController.getVerifyStatus.bind(authController),
});
// POST /api/auth/resend-verification - Resend verification email (requires JWT)
fastify.post('/auth/resend-verification', {
preHandler: [fastify.authenticate],
handler: authController.resendVerification.bind(authController),
});
// POST /api/auth/resend-verification-public - Resend verification by email (public, no JWT)
fastify.post('/auth/resend-verification-public', authController.resendVerificationPublic.bind(authController));
// GET /api/auth/user-status - Get user status for routing (requires JWT, verification exempt)
fastify.get('/auth/user-status', {
preHandler: [fastify.authenticate],
handler: authController.getUserStatus.bind(authController),
});
// GET /api/auth/security-status - Get security status (requires JWT)
fastify.get('/auth/security-status', {
preHandler: [fastify.authenticate],
handler: authController.getSecurityStatus.bind(authController),
});
// POST /api/auth/request-password-reset - Request password reset email (requires JWT)
fastify.post('/auth/request-password-reset', {
preHandler: [fastify.authenticate],
handler: authController.requestPasswordReset.bind(authController),
});
// POST /api/auth/track-logout - Track logout event for audit (requires JWT)
fastify.post('/auth/track-logout', {
preHandler: [fastify.authenticate],
handler: authController.trackLogout.bind(authController),
});
};