Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

617 B
Raw Blame
import { useAuth } from "@editor/auth/context";
import type { PortalAccessState } from "@editor-core/hooks/usePortalAccess";

export type { PortalAccessState };

/**
 * Self-hosted (and desktop): the Spring session carries `portalAccess`, so the
 * shared auth context is both the answer and the settled signal. See the core
 * seam for the contract.
 */
export function usePortalAccessState(): PortalAccessState {
  const { portalAccess, loading } = useAuth();
  return { granted: portalAccess === true, settled: !loading };
}

export function usePortalAccess(): boolean {
  return usePortalAccessState().granted;
}