Trying to see all sessions of all logged in users in Express Passport, and want be able to see who is currently logged in. Whats the best and quickest means?
I was t
In the case of using express-session (if store is default value: MemoryStore) you can get store object and sessions array from req object:
var sessions = req.sessionStore.sessions
For example (for me) it looks like that:
{
KT29eOp9XkzFfXWdz_UVUQMI4Qf3VTxE:
'{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},
"passport":{"user":"5a95b34b52670e19200ec48e"}}',
WW7BAhNNBbuFUsKQ0dbalgToEEfGES8p:
'{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},
"passport":{"user":"5a9d56a18149111cf0556991"}}'
}
user values in passport props are _id of your users in MongoDB User collection.