Add session validation UI and expose isValidating in auth context
- LoginPage now shows a loading spinner while validating the session - Redirect to dashboard automatically once validation completes and session is valid - Expose isValidating state through AuthProvider for components to track validation status - Update useAuth hook to return isValidating along with isAuthenticated Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -62,6 +62,8 @@ import { useSessionValidation } from "../hooks/useSessionValidation";
|
||||
export interface AuthContextValue {
|
||||
/** `true` when the backend considers the session valid. */
|
||||
isAuthenticated: boolean;
|
||||
/** `true` while the session is being validated on app mount. */
|
||||
isValidating: boolean;
|
||||
/**
|
||||
* Authenticate with the master password.
|
||||
* Throws an `ApiError` on failure.
|
||||
@@ -216,8 +218,8 @@ export function AuthProvider({
|
||||
}, []);
|
||||
|
||||
const value = useMemo<AuthContextValue>(
|
||||
() => ({ isAuthenticated, login, logout }),
|
||||
[isAuthenticated, login, logout],
|
||||
() => ({ isAuthenticated, isValidating, login, logout }),
|
||||
[isAuthenticated, isValidating, login, logout],
|
||||
);
|
||||
|
||||
// Show loading spinner while validating session on mount.
|
||||
|
||||
Reference in New Issue
Block a user