Add basic login/logout logic

This commit is contained in:
Johannes Zellner
2020-02-04 14:35:25 +01:00
parent 57e3180737
commit 0ae9be4de9
3 changed files with 69 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
exports = module.exports = {
get: get,
getByAccessToken: getByAccessToken,
delByAccessToken: delByAccessToken,
add: add,
del: del,
delByClientId: delByClientId,
@@ -35,6 +36,18 @@ function getByAccessToken(accessToken, callback) {
});
}
function delByAccessToken(accessToken, callback) {
assert.strictEqual(typeof accessToken, 'string');
assert.strictEqual(typeof callback, 'function');
database.query('DELETE FROM tokens WHERE accessToken = ?', [ accessToken ], function (error, result) {
if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error));
if (result.affectedRows !== 1) return callback(new BoxError(BoxError.NOT_FOUND, 'Token not found'));
return callback(null);
});
}
function get(id, callback) {
assert.strictEqual(typeof id, 'string');
assert.strictEqual(typeof callback, 'function');