This commit is contained in:
Manus Sandbox
2025-11-19 08:34:55 -05:00
parent 4d2ed3d5d8
commit 1313a45879
10 changed files with 11 additions and 962 deletions

View File

@@ -44,20 +44,7 @@ export function registerOAuthRoutes(app: Express) {
const cookieOptions = getSessionCookieOptions(req);
res.cookie(COOKIE_NAME, sessionToken, { ...cookieOptions, maxAge: ONE_YEAR_MS });
// Décoder le state pour obtenir l'URL de redirection
let redirectUrl = "/";
try {
redirectUrl = Buffer.from(state, 'base64').toString('utf-8');
// Si c'est une URL complète, extraire seulement le path
if (redirectUrl.startsWith('http')) {
const url = new URL(redirectUrl);
redirectUrl = url.pathname;
}
} catch (error) {
console.warn("[OAuth] Failed to decode state, redirecting to /", error);
}
res.redirect(302, redirectUrl);
res.redirect(302, "/");
} catch (error) {
console.error("[OAuth] Callback failed", error);
res.status(500).json({ error: "OAuth callback failed" });