passport-oauth2 icon indicating copy to clipboard operation
passport-oauth2 copied to clipboard

Dynamic redirect_uri from queryString ?

Open FullTS opened this issue 7 years ago • 2 comments

It is common that login page with a param url=xxx, will jump to url after login successfully.

Now callbackURL is static, could only be configured as a unique value.

Maybe it's better if it can have some dynamic param from url query string.

FullTS avatar Mar 06 '17 07:03 FullTS

It would be nice to have a setter for the callbackURL, much like it has been done here: https://github.com/jaredhanson/passport-oauth/issues/2

jgautheron avatar Apr 26 '17 15:04 jgautheron

it's easy enough to subclass, here is a currently working solution:

class MyStrategy extends OauthStrategy {
  authenticate(req: Request, options) {
    // tslint:disable-next-line:no-string-literal
    const callbackURL = options.callbackURL || this['_callbackURL']
    options.callbackURL = addReturnTo(req, callbackURL)
    return super.authenticate(req, options)
  }
}

itajaja avatar Mar 28 '18 00:03 itajaja