adriantanasa / connect-cloudant-store

NodeJS express-session storage connector for IBM Cloudant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

destroy function is missing a return statement

lmeerma opened this issue · comments

commented

Hi there,

the destroy function currently only returns when an error occurs since you're missing to return the callback function when the session was destroyed successfully.

CloudantStore.prototype.destroy = function(sid, fn) {
    debug('DESTROY session "%s"', sid);
    fn = fn || noop;
    // get _rev needed for delete
    // TODO check why db.head is not working
    self.db.get(self.prefix + sid).then(function(data) {
        // cleanup expired sessions
        self.db.destroy(self.prefix + sid, data._rev)
        .catch(function(err) {
            debug('DESTROY - DB error "%s" rev "%s" err "%s"', sid, data._rev,
            JSON.stringify(err));
            self.emit('error', err);
            return fn(err);
        });
    }).catch(function(err) {
        debug('DESTROY - DB GET failure "%s" err "%s"', sid, JSON.stringify(err));
        self.emit('error', err);
        return fn(err);
    });
};

After self.db.destroy(self.prefix + sid, data._rev) there should be a then method returning the callback function.