मैंने पहली बार persistent sessions with passport, mongodb and express पर देखा लेकिन यह मदद या समझ में नहीं आया।पासपोर्ट लगातार लॉगिन सत्र नहीं रख रहा है
मैं अपने website के साथ लगातार लॉग इन प्राप्त करने का प्रयास कर रहा हूं। मेरी धारावाहिक प्रक्रिया काम नहीं कर रही है।
// Passport needs to be able to serialize and deserialize users to support persistent login sessions
passport.serializeUser(function(user, done) {
console.log('serializing user:',user.username);
//return the unique id for the user
return done(null, user._id);
});
//Desieralize user will call with the unique id provided by serializeuser
passport.deserializeUser(function(id, done) {
User.findById(id, function(err, user) {
console.log('deserializing user:',user.username);
return done(err, user);
});
});
संपूर्ण पासपोर्ट फ़ाइल जिथब पर पाई जा सकती है।
मुझे लगता है कि समस्या यह है कि मुझे तुरंत deserialized मिलता है, या कम से कम console.logs क्या दिखाता है।
या यह मेरी सत्र के साथ हो सकता है:
var userSchema = new mongoose.Schema({
username : String,
password : String, //Hash
created_at : {type: Date, default : Date.now}
});
मदद के लिए धन्यवाद:
app.use(session({
secret: 'keyboard cat',
cookie : {
maxAge: 3600000 // see below
}
}));
यहाँ मेरे उपयोगकर्ता स्कीमा है!
क्षमा करें मैंने अभी यह जवाब देखा है। मैं एक नजर मार लूगां! यह ठीक लगता है – Manu