Fix: small problem with this context in Auth.js

This commit is contained in:
lukeIam 2023-03-24 18:31:58 +01:00
parent be53b31712
commit 08676a675a

View File

@ -48,22 +48,22 @@ class Auth {
process.nextTick(function () { process.nextTick(function () {
// only store username and id to session // only store username and id to session
// TODO: do we want to store more info in the session? // TODO: do we want to store more info in the session?
return cb(null, { return cb(null, JSON.stringify({
"username": user.username, "username": user.username,
"id": user.id, "id": user.id,
}); }));
}); });
}); });
// define how to deseralize a user (use the username to get it from the database) // define how to deseralize a user (use the username to get it from the database)
passport.deserializeUser(function (user, cb) { passport.deserializeUser((function (user, cb) {
process.nextTick(function () { process.nextTick((function () {
parsedUserInfo = JSON.parse(user) const parsedUserInfo = JSON.parse(user)
// TODO: do the matching on username or better on id? // TODO: do the matching on username or better on id?
var dbUser = this.db.users.find(u => u.username.toLowerCase() === parsedUserInfo.username.toLowerCase()) var dbUser = this.db.users.find(u => u.username.toLowerCase() === parsedUserInfo.username.toLowerCase())
return cb(null, new User(dbUser)); return cb(null, new User(dbUser));
}); }).bind(this));
}); }).bind(this));
} }
/** /**