Comments (14)
Fixed!
You can now invalidate an existing login session by setting user to false
or null
when calling done
inside deserializeUser
.
passport.deserializeUser(function(obj, done) {
done(null, false); // invalidates the existing login session.
});
Most ORMs set the result to null
if the record wasn't found, as is the case with Mongoose. So, this will work as expected if you are deleting user records while they have an active session. In that case, findById sets user
to null, which is passed through to Passport and the session will be invalidated.
passport.deserializeUser(function(id, done) {
User.findById(id, function (err, user) {
done(err, user);
});
});
This is fixed in [email protected], which has just been published to the npm registry.
from passport.
I would note in the documentation that you have to return null
or false
. I tried returning undefined
instead of null
and came here through Google.
from passport.
A world where null
and false
are the same but are not the same as undefined
makes no sense. The following are true facts of Javascript:
null == false == undefined
null !== false !== undefined
Inventing your own truth table where null == false != undefined
makes things unnecessarily confusing.
from passport.
Just a heads up for folks stumbling across this—it turns out TypeORM
returns undefined
and not null. You should do something like (await User.findOne({where: {id: obj.id}})) || false
for Passport to work properly.
from passport.
Agreed. I'm leaning towards option 1 as the proper fix.
from passport.
strong +1 for one.
from passport.
+10086 for this issue...
from passport.
At least allowing the developer to handle the error would be key. +1 for at least exposing that.
from passport.
+1 on this. Is there a workaround for the issue right now?
from passport.
Hello guys, any idea when this will be fixed?
from passport.
I'm having this exact same issue on version 0.1.12 with passport-facebook.
from passport.
Thank you! This should definitely find it's way into the documentation.
from passport.
This working for me, put the next following commands in your terminal:
redis-cli
select 1
FLUSHALL
from passport.
created PR to fix undefined problem #975
from passport.
Related Issues (20)
- strategy.authenticate is not a function (passport-facebook)
- documentation does not work. https://www.passportjs.org/tutorials/google/ HOT 3
- Race condition in logout function HOT 10
- Laravel passport HOT 2
- Passport 0.6.0 regenerates session IDs, breaking custom logins
- Facebook Tutorial Register has no content HOT 1
- Prompt option is being ignored in nodejs when extending PassportStrategy
- Documentation Isuue HOT 1
- Passport authentication with client side generation
- TokenError: Code is invalid or expired HOT 2
- TypeError: LocalStrategy is not a constructor HOT 1
- Own session data is overwritten by passport HOT 5
- Facebook authentication no more working HOT 2
- passport-google-oauth20 passport.authenticate doesn't run HOT 7
- social login with yahoo using passprt js HOT 1
- https://www.passportjs.org/packages/ not found
- Passport Strategy for Facebook doesn't work
- local strategy deserializeUser not be used
- Add Discord Auth Strategy
- Add my Passport Strategies to website: Magalu (Magazine Luiza) and MercadoLivre (ML Brazil)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from passport.