Add tokendb.delByClientId()
This commit is contained in:
@@ -7,6 +7,7 @@ exports = module.exports = {
|
||||
get: get,
|
||||
add: add,
|
||||
del: del,
|
||||
delByClientId: delByClientId,
|
||||
getByIdentifier: getByIdentifier,
|
||||
delByIdentifier: delByIdentifier,
|
||||
getByIdentifierAndClientId: getByIdentifierAndClientId,
|
||||
@@ -69,6 +70,18 @@ function del(accessToken, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function delByClientId(clientId, callback) {
|
||||
assert.strictEqual(typeof clientId, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
database.query('DELETE FROM tokens WHERE clientId = ?', [ clientId ], function (error, result) {
|
||||
if (error) return callback(new DatabaseError(DatabaseError.INTERNAL_ERROR, error));
|
||||
if (result.affectedRows !== 1) return callback(new DatabaseError(DatabaseError.NOT_FOUND));
|
||||
|
||||
return callback(null);
|
||||
});
|
||||
}
|
||||
|
||||
function getByIdentifier(identifier, callback) {
|
||||
assert.strictEqual(typeof identifier, 'string');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
Reference in New Issue
Block a user