MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / redirect

Function redirect

apps/cloud/src/auth/doc-gate.ts:190–208  ·  view source on GitHub ↗
(
  location: string,
  options?: {
    /** Drop the (invalid) session + auth-hint cookies along the way. */
    readonly clearSession?: boolean;
    /** Persist a WorkOS-rotated sealed session (refresh tokens are single-use). */
    readonly refreshedSession?: string | undefined;
  },
)

Source from the content-addressed store, hash-verified

188 `${SESSION_COOKIE}=${sealed}; ${SESSION_COOKIE_ATTRIBUTES}; Max-Age=${SESSION_MAX_AGE}`;
189
190const redirect = (
191 location: string,
192 options?: {
193 /** Drop the (invalid) session + auth-hint cookies along the way. */
194 readonly clearSession?: boolean;
195 /** Persist a WorkOS-rotated sealed session (refresh tokens are single-use). */
196 readonly refreshedSession?: string | undefined;
197 },
198): Response => {
199 const headers = new Headers({ location });
200 if (options?.clearSession) {
201 headers.append("set-cookie", `${SESSION_COOKIE}=; ${SESSION_COOKIE_ATTRIBUTES}; Max-Age=0`);
202 headers.append("set-cookie", `${AUTH_HINT_COOKIE}=; Path=/; SameSite=Lax; Max-Age=0`);
203 }
204 if (options?.refreshedSession) {
205 headers.append("set-cookie", sessionSetCookie(options.refreshedSession));
206 }
207 return new Response(null, { status: 302, headers });
208};
209
210export const authGateMiddleware = createMiddleware({ type: "request" }).server(
211 async ({ pathname, request, next }) => {

Callers 2

doc-gate.tsFile · 0.70
secrets.tsxFile · 0.50

Calls 2

sessionSetCookieFunction · 0.85
appendMethod · 0.65

Tested by

no test coverage detected