-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
promisified
version of req.logout
#929
Comments
Using promisification since the logout function is async now: jaredhanson/passport#929
Beyond that, it sure seems like
means passport should have a semantic versioning update to 1.0.0, since this change breaks existing calls to logout. Agreed? |
As long as |
+1. It's long due to promisify this. So that we can use it like the following: try {
await req.logout();
return res.redirect('/login');
} catch (error) {
return next(error);
} By the way, |
@msrumon Example on how to promisify was posted on #536 (comment) |
Sorry if this has already been discussed (a quick search didn't give any hits).
Starting from
0.6.0
,req.logout
is an asynchronous function and requires a callback function. This is explained in the documentation https://www.passportjs.org/concepts/authentication/logout/:If possible, it would be nice to have a "promisified" version of
req.logout
available for writing more readable code. Another benefit: starting withexpress-5
(currently inbeta
), when functions returning a promise throw an error,express
will automatically callnext(err)
(https://expressjs.com/en/guide/error-handling.html). Writing apassport
basedlogout
route could then probably be simplified to something like:On a related note, in the current
logout
snippet example in the documentation, how isnext
made available to the callback function in cases ofreq.logout
throwing an error? I would expected something likeThanks 🙇
The text was updated successfully, but these errors were encountered: