Skip to content

Add Logout Endpoint and Dashboard Logout Button #1

Description

@alvarotech

Description

The application currently has authentication functionality with login and register features, but lacks a proper logout endpoint on the backend and a logout button in the dashboard UI. While the frontend has logout logic implemented in the auth context, we need:

  1. A backend logout endpoint following the project's hexagonal architecture
  2. A logout button in the dashboard header (top-right position) for easy access

Current State

  • ✅ Frontend logout logic exists in useAuthContext.tsx
  • ✅ Frontend auth service has logout function calling /api/v1/auth/logout
  • ❌ Backend /api/v1/auth/logout endpoint is missing
  • ❌ Dashboard lacks visible logout button

Requirements

Backend

  • Add POST /api/v1/auth/logout endpoint in /backend/src/infrastructure/web/routers/users.py
  • Follow hexagonal architecture patterns (use case → domain → infrastructure)
  • Handle token invalidation/blacklisting if needed
  • Return appropriate HTTP status codes

Frontend

  • Add logout button to dashboard header (/frontend/src/pages/home.page.tsx)
  • Position button in top-right corner of the header
  • Use existing useAuthContext hook for logout functionality
  • Ensure logout redirects to login page
  • Follow project's feature-based architecture and UI conventions

Acceptance Criteria

  • Backend endpoint POST /api/v1/auth/logout is implemented
  • Endpoint follows hexagonal architecture patterns
  • Endpoint returns 200 status on successful logout
  • Frontend dashboard has logout button in header top-right position
  • Logout button uses existing auth context logout function
  • Clicking logout button clears user session and redirects to /login
  • Button follows project's UI design patterns (Radix UI/TailwindCSS)
  • All existing authentication tests continue to pass
  • New functionality includes appropriate error handling

Technical Notes

Backend Implementation

  • Location: /backend/src/infrastructure/web/routers/users.py
  • Should be added near existing auth endpoints (register, login)
  • Consider if token blacklisting is needed for security
  • Follow existing dependency injection patterns

Frontend Implementation

  • Location: /frontend/src/pages/home.page.tsx header section
  • Use existing useAuthContext hook: const { logout } = useAuthContext()
  • Style with TailwindCSS to match existing UI components
  • Consider adding user email/avatar next to logout button

Priority

Medium - Important for user experience and security best practices

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions