Wire production domain, CORS for tenant subdomains, celery volume mounts, and nginx reverse proxy configs for apex, API, identity, auth, and wildcard tenants. Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
731 B
TypeScript
27 lines
731 B
TypeScript
"use client";
|
||
|
||
import { useAuth } from "@/hooks/useAuth";
|
||
import { useRouter } from "next/navigation";
|
||
import { useEffect } from "react";
|
||
|
||
export function AuthGuard({ children }: { children: React.ReactNode }) {
|
||
const { isAuthenticated, loading, login } = useAuth();
|
||
const router = useRouter();
|
||
|
||
useEffect(() => {
|
||
if (!loading && !isAuthenticated) {
|
||
login();
|
||
}
|
||
}, [loading, isAuthenticated, login]);
|
||
|
||
if (loading) {
|
||
return <p className="text-sm text-gray-500">در حال بررسی احراز هویت...</p>;
|
||
}
|
||
|
||
if (!isAuthenticated) {
|
||
return <p className="text-sm text-gray-500">در حال هدایت به صفحه ورود...</p>;
|
||
}
|
||
|
||
return <>{children}</>;
|
||
}
|