Fix: 401 al ingresar a la web de login para el panel de admin
This commit is contained in:
@@ -67,6 +67,13 @@ public class AuthController : ControllerBase
|
|||||||
return Ok(new { message = "Sesión cerrada" });
|
return Ok(new { message = "Sesión cerrada" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("status")]
|
||||||
|
[Microsoft.AspNetCore.Authorization.AllowAnonymous]
|
||||||
|
public IActionResult GetStatus()
|
||||||
|
{
|
||||||
|
return Ok(new { isAuthenticated = User.Identity?.IsAuthenticated ?? false });
|
||||||
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
// [SEGURIDAD] Endpoint solo para desarrollo
|
// [SEGURIDAD] Endpoint solo para desarrollo
|
||||||
[HttpPost("setup-admin")]
|
[HttpPost("setup-admin")]
|
||||||
|
|||||||
@@ -16,10 +16,11 @@ function App() {
|
|||||||
|
|
||||||
const checkAuth = async () => {
|
const checkAuth = async () => {
|
||||||
try {
|
try {
|
||||||
// Intentamos acceder a un recurso protegido para verificar la cookie
|
// Verificamos estado silenciosamente (sin generar 401 en consola)
|
||||||
await apiClient.get('/api/admin/contexto');
|
const response = await apiClient.get('/api/auth/status');
|
||||||
setIsAuthenticated(true);
|
setIsAuthenticated(response.data.isAuthenticated);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// Si falla la conexión (ej. 500), asumimos no autenticado
|
||||||
setIsAuthenticated(false);
|
setIsAuthenticated(false);
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user