Update auth.ts
Updated success and error redirect paths using ENV variables
This commit is contained in:
parent
c66e4f5c2a
commit
201087ee95
|
@ -204,13 +204,16 @@ export const googleCallback = async (ctx: any, next: any) => {
|
||||||
|
|
||||||
return passport.authenticate(
|
return passport.authenticate(
|
||||||
strategy,
|
strategy,
|
||||||
{ successRedirect: "/", failureRedirect: "/error" },
|
{
|
||||||
|
successRedirect: env.PASSPORT_GOOGLEAUTH_SUCCESS_REDIRECT,
|
||||||
|
failureRedirect: env.PASSPORT_GOOGLEAUTH_FAILURE_REDIRECT,
|
||||||
|
},
|
||||||
async (err: any, user: SSOUser, info: any) => {
|
async (err: any, user: SSOUser, info: any) => {
|
||||||
await passportCallback(ctx, user, err, info)
|
await passportCallback(ctx, user, err, info)
|
||||||
await context.identity.doInUserContext(user, ctx, async () => {
|
await context.identity.doInUserContext(user, ctx, async () => {
|
||||||
await events.auth.login("google-internal", user.email)
|
await events.auth.login("google-internal", user.email)
|
||||||
})
|
})
|
||||||
ctx.redirect("/")
|
ctx.redirect(env.PASSPORT_GOOGLEAUTH_SUCCESS_REDIRECT)
|
||||||
}
|
}
|
||||||
)(ctx, next)
|
)(ctx, next)
|
||||||
}
|
}
|
||||||
|
@ -269,13 +272,17 @@ export const oidcCallback = async (ctx: any, next: any) => {
|
||||||
|
|
||||||
return passport.authenticate(
|
return passport.authenticate(
|
||||||
strategy,
|
strategy,
|
||||||
{ successRedirect: "/", failureRedirect: "/error" },
|
{
|
||||||
|
successRedirect: env.PASSPORT_OIDCAUTH_SUCCESS_REDIRECT,
|
||||||
|
failureRedirect: env.PASSPORT_OIDCAUTH_FAILURE_REDIRECT,
|
||||||
|
},
|
||||||
async (err: any, user: SSOUser, info: any) => {
|
async (err: any, user: SSOUser, info: any) => {
|
||||||
await passportCallback(ctx, user, err, info)
|
await passportCallback(ctx, user, err, info)
|
||||||
await context.identity.doInUserContext(user, ctx, async () => {
|
await context.identity.doInUserContext(user, ctx, async () => {
|
||||||
await events.auth.login("oidc", user.email)
|
await events.auth.login("oidc", user.email)
|
||||||
})
|
})
|
||||||
ctx.redirect("/")
|
ctx.redirect(env.PASSPORT_OIDCAUTH_SUCCESS_REDIRECT)
|
||||||
}
|
}
|
||||||
)(ctx, next)
|
)(ctx, next)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue