diff --git a/backend/src/api/auth.ts b/backend/src/api/auth.ts index 1bb663b7..effd0c77 100644 --- a/backend/src/api/auth.ts +++ b/backend/src/api/auth.ts @@ -122,6 +122,7 @@ export function initAuth(router: express.Router) { "/auth/oauth-callback", passport.authenticate("oauth2", { failureRedirect: "/", session: false }), (req: Request, res: Response) => { + res.clearCookie("redir"); if (req.user && req.user.apiKey) { res.redirect( req.cookies.redir diff --git a/revampdashboard/src/routes/login-callback/+server.ts b/revampdashboard/src/routes/login-callback/+server.ts new file mode 100644 index 00000000..ab277565 --- /dev/null +++ b/revampdashboard/src/routes/login-callback/+server.ts @@ -0,0 +1,19 @@ +import { redirect } from '@sveltejs/kit'; +import type { RequestHandler } from './$types'; + +export const GET: RequestHandler = async ({ url, cookies }) => { + const apiKey = String(url.searchParams.get('apiKey') ?? ''); + const error = String(url.searchParams.get('error') ?? 'noAccess'); + + if (apiKey) { + cookies.set('apiKey', apiKey, { + httpOnly: true, + path: '/new', + secure: true, + sameSite: 'strict' + }); + return redirect(301, '/new/dashboard'); + } else { + return redirect(301, `/new/?error=${error}`); + } +};