Skip to content

Commit

A link to a workspace's Agents or Integrations asks a signed-out visitor to sign in and then opens it, as Chat and Docs do, instead of a 404

syntaqxcommitted Parent2d6e3d0Browse files
3 files+11−80/3 viewed
+4−3
1616 import { page } from "../../lib/meta";
1717 import { useRefreshWhile } from "../../lib/refresh";
1818 import { workspaceAgents } from "../../lib/services.server";
19−import { getViewer, roleIn } from "../../lib/session.server";
19+import { requireUser, roleIn } from "../../lib/session.server";
2020 import { money } from "../../lib/usage";
2121
2222 export function meta({ params, ...args }: Route.MetaArgs) {
2424 }
2525
2626 /** Agents mode's front page: the budget, what is waiting and working, the roster, and where the month went. */
27−export async function loader({ params, context }: Route.LoaderArgs): Promise<{ overview: AgentsOverview | null }> {
28− const viewer = getViewer(context);
27+export async function loader({ params, context, request }: Route.LoaderArgs): Promise<{ overview: AgentsOverview | null }> {
28+ // Signed out, sign in first (as Chat and Docs do), rather than a 404.
29+ const viewer = requireUser(context, request);
2930 if (!viewer || !roleIn(viewer, params.owner)) throw data(null, { status: 404 });
3031 return { overview: await readOrNull(workspaceAgents.overview(params.owner.toLowerCase(), viewer)) };
3132 }
+4−3
66
77 import type { Route } from "./+types/layout";
88 import { workspaceAgents } from "../../../lib/services.server";
9−import { getViewer, roleIn } from "../../../lib/session.server";
9+import { requireUser, roleIn } from "../../../lib/session.server";
1010
1111 /**
1212 * Agents mode: the workspace's agents, for its sidebar, and how many live
1414 */
1515 export type AgentsLayoutData = { slug: string; agents: WorkspaceAgent[] | null; live: Record<string, number> };
1616
17−export async function loader({ params, context }: Route.LoaderArgs): Promise<AgentsLayoutData> {
18− const viewer = getViewer(context);
17+export async function loader({ params, context, request }: Route.LoaderArgs): Promise<AgentsLayoutData> {
18+ // Signed out, sign in first (as Chat and Docs do), rather than a 404.
19+ const viewer = requireUser(context, request);
1920 if (!roleIn(viewer, params.owner)) throw data(null, { status: 404 });
2021 const slug = params.owner.toLowerCase();
2122 const [listed, live] = await Promise.all([
+3−2
1010 import { integrationsSection } from "../../lib/integration-sections";
1111 import { page } from "../../lib/meta";
1212 import { integrations, webhooks } from "../../lib/services.server";
13−import { getViewer, roleIn } from "../../lib/session.server";
13+import { requireUser, roleIn } from "../../lib/session.server";
1414
1515 export function meta({ params, ...args }: Route.MetaArgs) {
1616 return page(args, { title: `Integrations · ${params.owner} · g1t` });
2323 * GitHub import, webhooks); this page only finds them.
2424 */
2525 export async function loader({ params, context, request }: Route.LoaderArgs) {
26− const viewer = getViewer(context);
26+ // Signed out, sign in first (as Chat and Docs do), rather than a 404.
27+ const viewer = requireUser(context, request);
2728 const role = roleIn(viewer, params.owner);
2829 if (!role || !viewer) throw new Response(null, { status: 404 });
2930 const slug = params.owner.toLowerCase();