Fixes custom login callback never finishing the authentication process #805
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #340 #664 and probably #440 too.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Currently setting a custom handler for the login callback route, causes the login process to never finish correctly as if it wasn't set.
What is the new behavior?
This fixes it. By switching around the order of, first calling the custom handler, and then the passport middleware to do it's thing.
Does this PR introduce a breaking change?
Maybe. The documentation mentions the custom handler to have the
(req, res, next) => {}
signature, in that sense it didn't changed. But the code used to be able to handle(err, req, res, next) => {}
that is no more.I think this change makes sense, there's no actual error (besides anything you can infer from context) before going through passport and any other handlers. Applications can always register an error handler afterwards in the Express middleware chain, which should be the correct way to go about it.
Other information
Reviewers