File size: 514 Bytes
3e30e4e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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;
}