Add tokendb.delByClientId()

This commit is contained in:
Johannes Zellner
2016-06-09 15:42:52 +02:00
parent 9b9db6acf1
commit 1508a5c6b9
2 changed files with 34 additions and 7 deletions
+13
View File
@@ -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');