From 201087ee956fe8a6484ca4a333ac0de6afdf706a Mon Sep 17 00:00:00 2001 From: Vinoth Kirubakaran Date: Mon, 6 Mar 2023 20:57:24 +0530 Subject: [PATCH] Update auth.ts Updated success and error redirect paths using ENV variables --- .../worker/src/api/controllers/global/auth.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/worker/src/api/controllers/global/auth.ts b/packages/worker/src/api/controllers/global/auth.ts index 362723abd9..3327f7dc6d 100644 --- a/packages/worker/src/api/controllers/global/auth.ts +++ b/packages/worker/src/api/controllers/global/auth.ts @@ -204,13 +204,16 @@ export const googleCallback = async (ctx: any, next: any) => { return passport.authenticate( strategy, - { successRedirect: "/", failureRedirect: "/error" }, + { + successRedirect: env.PASSPORT_GOOGLEAUTH_SUCCESS_REDIRECT, + failureRedirect: env.PASSPORT_GOOGLEAUTH_FAILURE_REDIRECT, + }, async (err: any, user: SSOUser, info: any) => { await passportCallback(ctx, user, err, info) await context.identity.doInUserContext(user, ctx, async () => { await events.auth.login("google-internal", user.email) }) - ctx.redirect("/") + ctx.redirect(env.PASSPORT_GOOGLEAUTH_SUCCESS_REDIRECT) } )(ctx, next) } @@ -269,13 +272,17 @@ export const oidcCallback = async (ctx: any, next: any) => { return passport.authenticate( strategy, - { successRedirect: "/", failureRedirect: "/error" }, + { + successRedirect: env.PASSPORT_OIDCAUTH_SUCCESS_REDIRECT, + failureRedirect: env.PASSPORT_OIDCAUTH_FAILURE_REDIRECT, + }, async (err: any, user: SSOUser, info: any) => { await passportCallback(ctx, user, err, info) await context.identity.doInUserContext(user, ctx, async () => { await events.auth.login("oidc", user.email) }) - ctx.redirect("/") + ctx.redirect(env.PASSPORT_OIDCAUTH_SUCCESS_REDIRECT) } )(ctx, next) } +