feat: global platform v2 update
This commit is contained in:
@@ -5,8 +5,9 @@
|
||||
// ============================================================================
|
||||
|
||||
import React, { useEffect } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useRouter, useParams } from "next/navigation";
|
||||
import { useAuth } from "./auth-provider";
|
||||
import { isDemoWorkspace } from "@/lib/demo";
|
||||
|
||||
interface ProtectedRouteProps {
|
||||
children: React.ReactNode;
|
||||
@@ -15,12 +16,25 @@ interface ProtectedRouteProps {
|
||||
export const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ children }) => {
|
||||
const { user, loading } = useAuth();
|
||||
const router = useRouter();
|
||||
const params = useParams();
|
||||
|
||||
// Check if this is demo mode
|
||||
const workspaceId = params?.workspaceId as string | undefined;
|
||||
const isDemo = isDemoWorkspace(workspaceId);
|
||||
|
||||
useEffect(() => {
|
||||
// Skip auth check for demo mode
|
||||
if (isDemo) return;
|
||||
|
||||
if (!loading && !user) {
|
||||
router.push("/login");
|
||||
}
|
||||
}, [user, loading, router]);
|
||||
}, [user, loading, router, isDemo]);
|
||||
|
||||
// Demo mode - skip auth entirely
|
||||
if (isDemo) {
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user