Skip to content

Fix logout hanging issue by routing through AuthController#26

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-logo-redirect-logout-issue
Draft

Fix logout hanging issue by routing through AuthController#26
Copilot wants to merge 3 commits intomainfrom
copilot/fix-logo-redirect-logout-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 11, 2025

Problem

The system had a critical issue where clicking "Cerrar Sesión" (logout) would cause the application to hang indefinitely with a loading state, preventing users from successfully logging out. This was a regression from previous versions where logout worked correctly.

Root Cause

The logout link in the navigation header was pointing directly to PUBLIC_URL/logout_extremo.php, which bypassed the application's router and session management infrastructure. This direct file access caused issues with proper session cleanup and resulted in the hanging behavior.

// BEFORE - Direct file access (problematic)
<a href="<?php echo PUBLIC_URL; ?>/logout_extremo.php">
    <i class="bi bi-box-arrow-right"></i> Cerrar Sesión
</a>

Solution

Changed the logout link to use the router-based endpoint /logout, ensuring it goes through AuthController::logout() which handles session cleanup properly:

// AFTER - Router-based (fixed)
<a href="<?php echo BASE_URL; ?>/logout">
    <i class="bi bi-box-arrow-right"></i> Cerrar Sesión
</a>

This minimal one-line change ensures:

  • Logout flows through the proper controller method
  • Session is destroyed cleanly with proper cookie cleanup
  • Audit logging is performed with error handling
  • User is redirected to the home page showing "Bienvenido a RecaudaBot - Sistema Integral de Recaudación Municipal"
  • No hanging or loading issues occur

Files Changed

  • app/views/layout/header.php (line 185) - Updated logout link to use router

Testing

  1. Log in to the application with any valid user credentials
  2. Click on the user dropdown menu in the top-right navbar
  3. Click "Cerrar Sesión"
  4. Expected: User is immediately redirected to the home page with the welcome message
  5. Expected: Session is destroyed and user sees login/register options
  6. Expected: No hanging, loading, or stuck states

Additional Notes

The logo link was also verified and is working correctly - it already redirects to the home page (BASE_URL . '/') and displays the welcome message properly for both logged-in and logged-out users. No changes were needed for this functionality.

This fix follows the same proven pattern used by the login functionality and ensures consistency across all authentication-related actions in the application.

Original prompt

El sistema ya es funcional, repara lo siguiente:

Al dar clic en el logo debe redirigirse a la página de bienvenida en /public: : ‘Bienvenido a RecaudaBot - Sistema Integral de Recaudación Municipal’, la cual debe cargar con login o sin él siempre que le demos clic al logo.

Al dar clic en cerrar sesión al sistema se queda cargando y no avanza, Resolverlo en versiones anteriores cerraba correctamente la sesión.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 11, 2025 14:26
Co-authored-by: danjohn007 <77515822+danjohn007@users.noreply.github.com>
Co-authored-by: danjohn007 <77515822+danjohn007@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix logo redirect and session logout issues Fix logout hanging issue by routing through AuthController Oct 11, 2025
Copilot AI requested a review from danjohn007 October 11, 2025 14:37
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.

2 participants