feat: productionize learning engine and classroom
This commit is contained in:
@@ -5,6 +5,7 @@ import { AccessCodeModal } from '@/components/access-code-modal';
|
||||
import { useSettingsStore } from '@/lib/store/settings';
|
||||
|
||||
export function AccessCodeGuard({ children }: { children: ReactNode }) {
|
||||
const isOpsDeployment = process.env.NEXT_PUBLIC_OPENMAIC_DEPLOYMENT_ROLE === 'ops';
|
||||
const [status, setStatus] = useState<{
|
||||
enabled: boolean;
|
||||
authenticated: boolean;
|
||||
@@ -12,6 +13,10 @@ export function AccessCodeGuard({ children }: { children: ReactNode }) {
|
||||
}>({ enabled: false, authenticated: false, loading: true });
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpsDeployment || new URLSearchParams(window.location.search).get('embedded') === '1') {
|
||||
setStatus({ enabled: false, authenticated: true, loading: false });
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
fetch('/api/access-code/status')
|
||||
.then((res) => res.json())
|
||||
@@ -33,7 +38,7 @@ export function AccessCodeGuard({ children }: { children: ReactNode }) {
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
}, [isOpsDeployment]);
|
||||
|
||||
const needsAuth = !status.loading && status.enabled && !status.authenticated;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user