diff --git a/lib/cartodb/controllers/named_maps_admin.js b/lib/cartodb/controllers/named_maps_admin.js index ef49e652..1555273b 100644 --- a/lib/cartodb/controllers/named_maps_admin.js +++ b/lib/cartodb/controllers/named_maps_admin.js @@ -27,7 +27,7 @@ NamedMapsAdminController.prototype.register = function (app) { localsMiddleware(), credentialsMiddleware(), checkContentType({ action: 'POST', label: 'POST TEMPLATE' }), - authorizedByAPIKey(this.authApi, 'create', 'POST TEMPLATE'), + authorizedByAPIKey({ authApi: this.authApi, action: 'create', label: 'POST TEMPLATE' }), createTemplate(this.templateMaps), sendResponse() ); @@ -39,7 +39,7 @@ NamedMapsAdminController.prototype.register = function (app) { localsMiddleware(), credentialsMiddleware(), checkContentType({ action: 'PUT', label: 'PUT TEMPLATE' }), - authorizedByAPIKey(this.authApi, 'update', 'PUT TEMPLATE'), + authorizedByAPIKey({ authApi: this.authApi, action: 'update', label: 'PUT TEMPLATE' }), updateTemplate(this.templateMaps), sendResponse() ); @@ -50,7 +50,7 @@ NamedMapsAdminController.prototype.register = function (app) { userMiddleware(), localsMiddleware(), credentialsMiddleware(), - authorizedByAPIKey(this.authApi, 'get', 'GET TEMPLATE'), + authorizedByAPIKey({ authApi: this.authApi, action: 'get', label: 'GET TEMPLATE' }), retrieveTemplate(this.templateMaps), sendResponse() ); @@ -61,7 +61,7 @@ NamedMapsAdminController.prototype.register = function (app) { userMiddleware(), localsMiddleware(), credentialsMiddleware(), - authorizedByAPIKey(this.authApi, 'delete', 'DELETE TEMPLATE'), + authorizedByAPIKey({ authApi: this.authApi, action: 'delete', label: 'DELETE TEMPLATE' }), destroyTemplate(this.templateMaps), sendResponse() ); @@ -72,7 +72,7 @@ NamedMapsAdminController.prototype.register = function (app) { userMiddleware(), localsMiddleware(), credentialsMiddleware(), - authorizedByAPIKey(this.authApi, 'list', 'GET TEMPLATE LIST'), + authorizedByAPIKey({ authApi: this.authApi, action: 'list', label: 'GET TEMPLATE LIST' }), listTemplates(this.templateMaps), sendResponse() ); @@ -95,7 +95,7 @@ function checkContentType ({ action, label }) { }; } -function authorizedByAPIKey (authApi, action, label) { +function authorizedByAPIKey ({ authApi, action, label }) { return function authorizedByAPIKeyMiddleware (req, res, next) { const { user } = res.locals;