UNPKG

openhim-core

Version:

The OpenHIM core application that provides logging and routing of http requests

38 lines (29 loc) 814 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.authoriseUser = authoriseUser; exports.koaMiddleware = koaMiddleware; var _channels = require("../model/channels"); var _config = require("../config"); var _util = require("util"); function authoriseUser(ctx, done) { return _channels.ChannelModel.findOne({ _id: ctx.request.header['channel-id'] }, (err, channel) => { if (err) { return done(err); } ctx.authorisedChannel = channel; return done(null, channel); }); } /* * Koa middleware for bypassing authorisation for polling */ async function koaMiddleware(ctx, next) { const _authoriseUser = (0, _util.promisify)(authoriseUser); await _authoriseUser(ctx); await next(); } //# sourceMappingURL=pollingBypassAuthorisation.js.map