SessionStore: Use an arrow function to avoid `this` juggling

pull/4313/head
Richard Hansen 2020-09-21 16:41:45 -04:00 committed by John McLear
parent de98852da6
commit 5d2c438e3e
1 changed files with 2 additions and 4 deletions

View File

@ -19,15 +19,13 @@ SessionStore.prototype.__proto__ = Store.prototype;
SessionStore.prototype.get = function(sid, fn) {
messageLogger.debug('GET ' + sid);
var self = this;
db.get("sessionstorage:" + sid, function(err, sess) {
db.get('sessionstorage:' + sid, (err, sess) => {
if (sess) {
sess.cookie.expires = 'string' == typeof sess.cookie.expires ? new Date(sess.cookie.expires) : sess.cookie.expires;
if (!sess.cookie.expires || new Date() < sess.cookie.expires) {
fn(null, sess);
} else {
self.destroy(sid, fn);
this.destroy(sid, fn);
}
} else {
fn();