mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2025-12-19 05:47:46 +00:00
major merge of features from the hosted branch that was created temporarily during the initial launch of jambonz.org
24 lines
634 B
JavaScript
24 lines
634 B
JavaScript
const router = require('express').Router();
|
|
const debug = require('debug')('jambonz:api-server');
|
|
const {hashString} = require('../../utils/password-utils');
|
|
const sysError = require('../error');
|
|
|
|
router.post('/', async(req, res) => {
|
|
const {logger, addKey} = req.app.locals;
|
|
const {jwt} = req.user;
|
|
|
|
debug(`adding jwt to blacklist: ${jwt}`);
|
|
|
|
try {
|
|
/* add key to blacklist */
|
|
const s = `jwt:${hashString(jwt)}`;
|
|
const result = await addKey(s, '1', 3600);
|
|
debug(`result from adding ${s}: ${result}`);
|
|
res.sendStatus(204);
|
|
} catch (err) {
|
|
sysError(logger, res, err);
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|