how does Express, Passportjs, allow users to log in in only one place?
// passport
// passportsessionsession
// mongoosemongodb
// sessionpassportsession
//
passport.serializeUser((user, done) => {
const sessionUser = { _id: user._id, username: user.username }
done(null, sessionUser)
})
passport.deserializeUser((id, done) => {
User.findById(id, (err, user) => {
done(null, user)
})
})
my current idea is to judge the user"s id, when logging in. If the user"s id exists in session, first delete the session record in the session table, and then call passport"s done. The implementation only allows users to log in in one place
but without session"s model, how can I handle it more elegantly?