mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 04:18:05 +00:00
fix(ui): redirect to login when auth check fails from remote access
When the auth check API call fails (e.g., 403 from the localhost security middleware), the catch block assumed no auth was needed and marked the user as authenticated. This caused a silently broken dashboard with no providers and no error feedback. Now treats auth check failure as auth-required, redirecting to the login page where users get a clear prompt to configure credentials.
This commit is contained in:
@@ -47,9 +47,10 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
||||
setUsername(res.username);
|
||||
})
|
||||
.catch(() => {
|
||||
// If check fails, assume no auth required (backward compat)
|
||||
setAuthRequired(false);
|
||||
setIsAuthenticated(true);
|
||||
// If auth check fails (e.g., 403 from remote access without auth configured),
|
||||
// treat as auth required so the login page appears instead of a broken dashboard.
|
||||
setAuthRequired(true);
|
||||
setIsAuthenticated(false);
|
||||
})
|
||||
.finally(() => setLoading(false));
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user