Skip to content

Conversation

@chriscarrollsmith
Copy link
Contributor

Summary

I've successfully resolved issue #141 by ensuring the logout button renders in exception handlers. Here's what I did:

Changes Made

  1. Added get_user_from_request helper function in utils/core/dependencies.py:327-349
  • This function extracts user information from request cookies without using Depends()
  • Exception handlers can't use dependency injection, so this manual extraction is necessary
  1. Updated exception handlers in main.py to pass user context to templates:
  • password_validation_exception_handler (main.py:95-109)
  • validation_exception_handler (main.py:114-165)
  • http_exception_handler (main.py:170-177)
  • general_exception_handler (main.py:182-196)

Testing & Quality Checks

  • ✅ Linter (mypy): Passed with no issues
  • ⚠️ Test suite: Could not fully run due to Docker not being available in this environment (database required)
  • 120 tests passed that don't require database
  • 135 tests errored due to missing database connection
  • Tests will run properly in CI/CD with Docker available

Committed & Pushed

  • Commit: db8d4a8 - "fix: ensure logout button renders in exception handlers by passing user context"
  • Branch: claude/fix-logout-button-middleware-011CV4YMNuENtZof9YSuHSxf
  • Successfully pushed to remote

The changes follow the same pattern used in the fork referenced in issue #141 and will ensure that logged-in users see the logout button on all error pages.

Fixes #141

…er context

Add get_user_from_request helper function to extract user from cookies in exception
handlers where Depends() cannot be used. Update all exception handlers (password
validation, request validation, HTTP exceptions, and general exceptions) to retrieve
and pass user to templates, enabling logout button visibility on error pages.

Fixes #141
@chriscarrollsmith chriscarrollsmith self-assigned this Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make sure logout button renders in middleware exception handlers

3 participants