How does Express, Passportjs, allow users to log in in only one place?

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?

Mar.12,2021

how to understand that there is only one place? Whether to lock ip or browser coockie?
as far as I know, oauth2.0 already has this feature


try express-js-passport-js-how-to-restrict-multiple-login-by-the-same-user

passport-one-session-per-user

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38320-344bf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38320-344bf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?