Follow middleware pattern, should return a function as the actual middleware
This commit is contained in:
parent
f6f59023b4
commit
b0c924ca03
@ -12,7 +12,7 @@ AnalysesController.prototype.register = function (app) {
|
||||
app.get(
|
||||
`${app.base_url_mapconfig}/analyses/catalog`,
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
this.prepareContext,
|
||||
this.createPGClient(),
|
||||
this.getDataFromQuery({ queryTemplate: catalogQueryTpl, key: 'catalog' }),
|
||||
|
@ -49,7 +49,7 @@ LayergroupController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/:token/:z/:x/:y@:scale_factor?x.:format',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
this.prepareContext,
|
||||
this.tile.bind(this),
|
||||
vectorError()
|
||||
@ -58,7 +58,7 @@ LayergroupController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/:token/:z/:x/:y.:format',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
this.prepareContext,
|
||||
this.tile.bind(this),
|
||||
vectorError()
|
||||
@ -67,7 +67,7 @@ LayergroupController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/:token/:layer/:z/:x/:y.(:format)',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
validateLayerRouteMiddleware,
|
||||
this.prepareContext,
|
||||
this.layer.bind(this),
|
||||
@ -77,7 +77,7 @@ LayergroupController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/:token/:layer/attributes/:fid',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
this.prepareContext,
|
||||
this.attributes.bind(this)
|
||||
);
|
||||
@ -85,7 +85,7 @@ LayergroupController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/static/center/:token/:z/:lat/:lng/:width/:height.:format',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
allowQueryParams(['layer']),
|
||||
this.prepareContext,
|
||||
this.center.bind(this)
|
||||
@ -94,7 +94,7 @@ LayergroupController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/static/bbox/:token/:west,:south,:east,:north/:width/:height.:format',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
allowQueryParams(['layer']),
|
||||
this.prepareContext,
|
||||
this.bbox.bind(this)
|
||||
@ -121,7 +121,7 @@ LayergroupController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/:token/dataview/:dataviewName',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
allowQueryParams(allowedDataviewQueryParams),
|
||||
this.prepareContext,
|
||||
this.dataview.bind(this)
|
||||
@ -130,7 +130,7 @@ LayergroupController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/:token/:layer/widget/:dataviewName',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
allowQueryParams(allowedDataviewQueryParams),
|
||||
this.prepareContext,
|
||||
this.dataview.bind(this)
|
||||
@ -139,7 +139,7 @@ LayergroupController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/:token/dataview/:dataviewName/search',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
allowQueryParams(allowedDataviewQueryParams),
|
||||
this.prepareContext,
|
||||
this.dataviewSearch.bind(this)
|
||||
@ -148,7 +148,7 @@ LayergroupController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/:token/:layer/widget/:dataviewName/search',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
allowQueryParams(allowedDataviewQueryParams),
|
||||
this.prepareContext,
|
||||
this.dataviewSearch.bind(this)
|
||||
@ -157,7 +157,7 @@ LayergroupController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/:token/analysis/node/:nodeId',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
this.prepareContext,
|
||||
this.analysisNodeStatus.bind(this)
|
||||
);
|
||||
|
@ -69,7 +69,7 @@ MapController.prototype.composeCreateMapMiddleware = function (useTemplate = fal
|
||||
|
||||
return [
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
allowQueryParams(['aggregation']),
|
||||
this.prepareContext,
|
||||
this.initProfiler(isTemplateInstantiation),
|
||||
|
@ -44,7 +44,7 @@ NamedMapsController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_templated + '/:template_id/:layer/:z/:x/:y.(:format)',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
this.prepareContext,
|
||||
this.getNamedMapProvider('NAMED_MAP_TILE'),
|
||||
this.getAffectedTables(),
|
||||
@ -61,7 +61,7 @@ NamedMapsController.prototype.register = function(app) {
|
||||
app.get(
|
||||
app.base_url_mapconfig + '/static/named/:template_id/:width/:height.:format',
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
allowQueryParams(['layer', 'zoom', 'lon', 'lat', 'bbox']),
|
||||
this.prepareContext,
|
||||
this.getNamedMapProvider('STATIC_VIZ_MAP'),
|
||||
|
@ -23,7 +23,7 @@ NamedMapsAdminController.prototype.register = function (app) {
|
||||
app.post(
|
||||
`${base_url_templated}/`,
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
localsMiddleware,
|
||||
credentialsMiddleware(),
|
||||
this.checkContentType('POST', 'POST TEMPLATE'),
|
||||
@ -34,7 +34,7 @@ NamedMapsAdminController.prototype.register = function (app) {
|
||||
app.put(
|
||||
`${base_url_templated}/:template_id`,
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
localsMiddleware,
|
||||
credentialsMiddleware(),
|
||||
this.checkContentType('PUT', 'PUT TEMPLATE'),
|
||||
@ -45,7 +45,7 @@ NamedMapsAdminController.prototype.register = function (app) {
|
||||
app.get(
|
||||
`${base_url_templated}/:template_id`,
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
localsMiddleware,
|
||||
credentialsMiddleware(),
|
||||
this.authorizedByAPIKey('get', 'GET TEMPLATE'),
|
||||
@ -55,7 +55,7 @@ NamedMapsAdminController.prototype.register = function (app) {
|
||||
app.delete(
|
||||
`${base_url_templated}/:template_id`,
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
localsMiddleware,
|
||||
credentialsMiddleware(),
|
||||
this.authorizedByAPIKey('delete', 'DELETE TEMPLATE'),
|
||||
@ -65,7 +65,7 @@ NamedMapsAdminController.prototype.register = function (app) {
|
||||
app.get(
|
||||
`${base_url_templated}/`,
|
||||
cors(),
|
||||
userMiddleware,
|
||||
userMiddleware(),
|
||||
localsMiddleware,
|
||||
credentialsMiddleware(),
|
||||
this.authorizedByAPIKey('list', 'GET TEMPLATE LIST'),
|
||||
|
@ -1,8 +1,11 @@
|
||||
var CdbRequest = require('../models/cdb_request');
|
||||
var cdbRequest = new CdbRequest();
|
||||
|
||||
module.exports = function userMiddleware(req, res, next) {
|
||||
res.locals.user = cdbRequest.userByReq(req);
|
||||
module.exports = function user () {
|
||||
var cdbRequest = new CdbRequest();
|
||||
|
||||
next();
|
||||
return function userMiddleware(req, res, next) {
|
||||
res.locals.user = cdbRequest.userByReq(req);
|
||||
|
||||
next();
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user