From 89270b8358bd9b93cc6358ce03d574e24b4eefb7 Mon Sep 17 00:00:00 2001 From: Celia Amador Date: Thu, 27 Nov 2025 12:30:13 +0100 Subject: [PATCH] Do now show login error before flow starts --- apps/standalone/src/app/context/AuthContext.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/standalone/src/app/context/AuthContext.ts b/apps/standalone/src/app/context/AuthContext.ts index 0a8272e82..e08aa15da 100644 --- a/apps/standalone/src/app/context/AuthContext.ts +++ b/apps/standalone/src/app/context/AuthContext.ts @@ -102,7 +102,14 @@ export const useAuthContext = () => { }); if (resp.status === 401) { - // Extract error message from response if available + const isOnAuthPage = ['/login', '/callback'].includes(window.location.pathname); + if (!isOnAuthPage) { + // The user is not authenticated - start the login process, and do not show any authentication errors yet + setLoading(false); + redirectToLogin(); + return; + } + let errorMessage = t('Authentication failed. Please try logging in again.'); try { const contentType = resp.headers.get('content-type'); @@ -119,10 +126,6 @@ export const useAuthContext = () => { // If parsing fails, use default error message } setError(errorMessage); - // Don't redirect if we're already on the login or login callback pages - if (!['/login', '/callback'].includes(window.location.pathname)) { - redirectToLogin(); - } setLoading(false); return; }