MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / loader

Function loader

apps/webapp/app/routes/invite-accept.tsx:6–47  ·  view source on GitHub ↗
({ request }: LoaderFunctionArgs)

Source from the content-addressed store, hash-verified

4import { getUser } from "~/services/session.server";
5
6export async function loader({ request }: LoaderFunctionArgs) {
7 const user = await getUser(request);
8
9 const url = new URL(request.url);
10 const token = url.searchParams.get("token");
11
12 if (!token) {
13 return redirectWithErrorMessage(
14 "/",
15 request,
16 "Invalid invite URL. Please ask the person who invited you to send another invite.",
17 { ephemeral: false }
18 );
19 }
20
21 const invite = await getInviteFromToken({ token });
22 if (!invite) {
23 return redirectWithErrorMessage(
24 "/",
25 request,
26 "Invite not found. Please ask the person who invited you to send another invite.",
27 { ephemeral: false }
28 );
29 }
30
31 if (!user) {
32 return redirectWithSuccessMessage("/", request, "Please log in to accept the invite.", {
33 ephemeral: false,
34 });
35 }
36
37 if (invite.email !== user.email) {
38 return redirectWithErrorMessage(
39 "/",
40 request,
41 `This invite is for ${invite.email}, but you are logged in as ${user.email}.`,
42 { ephemeral: false }
43 );
44 }
45
46 return redirectWithSuccessMessage("/", request, "Invite retrieved");
47}

Callers

nothing calls this directly

Calls 5

getUserFunction · 0.90
redirectWithErrorMessageFunction · 0.90
getInviteFromTokenFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…