mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
SessionStore: Use EC6 class syntax
This fixes a minor bug where the SessionStore constructor did not call the base class constructor.
This commit is contained in:
parent
0504e07eb4
commit
bee91a0bd1
1 changed files with 25 additions and 27 deletions
|
@ -13,35 +13,33 @@ const log4js = require('ep_etherpad-lite/node_modules/log4js');
|
||||||
|
|
||||||
const logger = log4js.getLogger('SessionStore');
|
const logger = log4js.getLogger('SessionStore');
|
||||||
|
|
||||||
const SessionStore = module.exports = function SessionStore() {};
|
module.exports = class SessionStore extends Store {
|
||||||
|
get(sid, fn) {
|
||||||
SessionStore.prototype.__proto__ = Store.prototype;
|
logger.debug('GET ' + sid);
|
||||||
|
db.get('sessionstorage:' + sid, (err, sess) => {
|
||||||
SessionStore.prototype.get = function(sid, fn) {
|
if (sess) {
|
||||||
logger.debug('GET ' + sid);
|
sess.cookie.expires = ('string' == typeof sess.cookie.expires
|
||||||
db.get('sessionstorage:' + sid, (err, sess) => {
|
? new Date(sess.cookie.expires) : sess.cookie.expires);
|
||||||
if (sess) {
|
if (!sess.cookie.expires || new Date() < sess.cookie.expires) {
|
||||||
sess.cookie.expires = ('string' == typeof sess.cookie.expires
|
fn(null, sess);
|
||||||
? new Date(sess.cookie.expires) : sess.cookie.expires);
|
} else {
|
||||||
if (!sess.cookie.expires || new Date() < sess.cookie.expires) {
|
this.destroy(sid, fn);
|
||||||
fn(null, sess);
|
}
|
||||||
} else {
|
} else {
|
||||||
this.destroy(sid, fn);
|
fn();
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
fn();
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
SessionStore.prototype.set = function(sid, sess, fn) {
|
set(sid, sess, fn) {
|
||||||
logger.debug('SET ' + sid);
|
logger.debug('SET ' + sid);
|
||||||
db.set('sessionstorage:' + sid, sess);
|
db.set('sessionstorage:' + sid, sess);
|
||||||
if (fn) process.nextTick(fn);
|
if (fn) process.nextTick(fn);
|
||||||
};
|
}
|
||||||
|
|
||||||
SessionStore.prototype.destroy = function(sid, fn) {
|
destroy(sid, fn) {
|
||||||
logger.debug('DESTROY ' + sid);
|
logger.debug('DESTROY ' + sid);
|
||||||
db.remove('sessionstorage:' + sid);
|
db.remove('sessionstorage:' + sid);
|
||||||
if (fn) process.nextTick(fn);
|
if (fn) process.nextTick(fn);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue