antes de alterar login
This commit is contained in:
@@ -11,6 +11,7 @@ export default function AuthGuard({ children }: { children: React.ReactNode }) {
|
||||
|
||||
useEffect(() => {
|
||||
if (!loading) {
|
||||
// If user is not authenticated and not on a public page, redirect to login
|
||||
if (!user && !pathname.startsWith("/login") && !pathname.startsWith("/register")) {
|
||||
router.push("/login");
|
||||
}
|
||||
@@ -25,8 +26,8 @@ export default function AuthGuard({ children }: { children: React.ReactNode }) {
|
||||
);
|
||||
}
|
||||
|
||||
// Se não estiver logado e não estiver numa rota pública, não renderiza nada
|
||||
// (o useEffect vai redirecionar)
|
||||
// If not authenticated and not on a public page, don't render children
|
||||
// (the useEffect will redirect)
|
||||
if (!user && !pathname.startsWith("/login") && !pathname.startsWith("/register")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user