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

Function redirect

apps/cloud/src/auth/doc-gate.ts:200–218  ·  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

198 `${SESSION_COOKIE}=${sealed}; ${SESSION_COOKIE_ATTRIBUTES}; Max-Age=${SESSION_MAX_AGE}`;
199
200const redirect = (
201 location: string,
202 options?: {
203 /** Drop the (invalid) session + auth-hint cookies along the way. */
204 readonly clearSession?: boolean;
205 /** Persist a WorkOS-rotated sealed session (refresh tokens are single-use). */
206 readonly refreshedSession?: string | undefined;
207 },
208): Response => {
209 const headers = new Headers({ location });
210 if (options?.clearSession) {
211 headers.append("set-cookie", `${SESSION_COOKIE}=; ${SESSION_COOKIE_ATTRIBUTES}; Max-Age=0`);
212 headers.append("set-cookie", `${AUTH_HINT_COOKIE}=; Path=/; SameSite=Lax; Max-Age=0`);
213 }
214 if (options?.refreshedSession) {
215 headers.append("set-cookie", sessionSetCookie(options.refreshedSession));
216 }
217 return new Response(null, { status: 302, headers });
218};
219
220export const authGateMiddleware = createMiddleware({ type: "request" }).server(
221 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