feat: unify GitHub sign-in and connect OAuth for gists

This commit is contained in:
tdurieux
2026-09-10 18:20:56 +02:00
parent 82510628f7
commit 99a50cad7b
16 changed files with 251 additions and 53 deletions
+15
View File
@@ -20,3 +20,18 @@ export function getLoginToken(
}
return null;
}
export function safeAuthReturnTo(value: unknown, fallback = "/dashboard"): string {
return typeof value === "string" && /^\/(?:(?:anonymize|pull-request-anonymize|gist-anonymize)(?:\/[\w-]+)?|connections|dashboard)(?:\?[^\\\r\n]*)?$/.test(value) ? value : fallback;
}
export type OAuthContext = { ownerId?: string; githubId?: string; returnTo: string; expires: number; recovery?: boolean };
declare module "express-session" {
interface SessionData {
githubRecovery?: OAuthContext;
githubOAuthFlow?: OAuthContext;
}
}
declare module "express-serve-static-core" {
interface Request { githubOAuthContext?: OAuthContext; }
}