Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
'use client'
import { createContext, useContext } from 'react'
import { useAuth } from '@components/AuthContext'
import { LoginPanel } from '@components/LoginPanel'
import type { AuthGateProps } from './types'
const AuthGateContext = createContext(false)
export function AuthGate({ children }: AuthGateProps) {
const isInsideAuthGate = useContext(AuthGateContext)
if (isInsideAuthGate) return <>{children}</>
return <AuthGateBoundary>{children}</AuthGateBoundary>
}
function AuthGateBoundary({ children }: AuthGateProps) {
const { authState } = useAuth()
if (authState.isLoading) {
return (
<main className="cu-app cu-app--auth">
<div className="cu-card cu-card--auth">
<div className="cu-card__body">
<div
className="profile-skeleton"
role="status"
aria-label="Loading profile session"
aria-busy="true"
>
<div className="profile-skeleton__row">
<span className="profile-skeleton__line profile-skeleton__line--medium" />
<span className="profile-skeleton__line" />
<span className="profile-skeleton__line profile-skeleton__line--short" />
</div>
</div>
</div>
</div>
</main>
)
}
if (!authState.isLoggedIn) {
return <LoginPanel />
}
return <AuthGateContext.Provider value>{children}</AuthGateContext.Provider>
}