EMAILOUT / frontend /src /components /auth /RequireAuth.jsx
Seth
update
3e30e4e
Raw
History Blame Contribute Delete
514 Bytes
import React from 'react';
import { useAuth } from '@/context/AuthContext';
import SignIn from '@/pages/SignIn';
/**
* Blocks the app until the user has a valid Google session.
* API routes remain protected server-side; this prevents browsing the UI while signed out.
*/
export default function RequireAuth({ children }) {
const { phase, signedIn } = useAuth();
if (phase === 'loading') {
return <SignIn />;
}
if (!signedIn) {
return <SignIn />;
}
return children;
}