-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Call res.redirect
after user's handler
code for login callback
#3
Call res.redirect
after user's handler
code for login callback
#3
Conversation
039e92d
to
1b98d17
Compare
1b98d17
to
13c839f
Compare
src/connectUtil.js
Outdated
const afterCustomNextHandler = (err) => { | ||
if (err) { | ||
next(err); | ||
} else if (!res._headerSent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the res._headerSent
? looks like a private field, should the middleware depend on it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to writableEnded
expressjs/express#743
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: express v4 seems to have a public accessor for headersSent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's the case, we probably should be able to keep it.
https://github.com/okta/okta-oidc-middleware/blob/master/package.json#L44
Call `res.redirect` after user's `handler` code for login callback
559cd0d
to
b7e00ac
Compare
OKTA-306438 <<<Jenkins Check-In of Tested SHA: b7e00ac for [email protected]>>> Artifact: okta-oidc-middleware Files changed count: 3 PR Link: "#3"
OKTA-306438 <<<Jenkins Check-In of Tested SHA: b7e00ac for [email protected]>>> Artifact: okta-oidc-middleware Files changed count: 3 PR Link: "#3"
OKTA-306438 <<<Jenkins Check-In of Tested SHA: b7e00ac for [email protected]>>> Artifact: okta-oidc-middleware Files changed count: 3 PR Link: "#3"
Internal ref: OKTA-306438
Resolves okta/okta-oidc-js#340
Overseedes okta/okta-oidc-js#805
This PR improves case when user defines
routes.loginCallback.handler
Description of this function in readme:
Current behavior
The developer needs to manually call
res.redirect()
inhandler
.This requirement is not explicitly covered in readme and can lead to confusion (see okta/okta-oidc-js#340)
However, it can be useful to give developer the power to manually set redirect path after authentication.
For example, developer can use
req.userContext.userinfo.locale
New behavior
If developer did not call
res.redirect()
inhandler
, it will be called automatically with correct value (routes.loginCallback.afterCallback
) innext()
.Otherwise, if developer have manually called
res.redirect()
with the value he needs,next()
will do nothing.