- Updating routes with security
This commit is contained in:
@@ -2,8 +2,8 @@ const errors = require('restify-errors');
|
||||
|
||||
const Install = require('../models/install');
|
||||
|
||||
module.exports = function(server) {
|
||||
server.post('/installs', (req, res, next) => {
|
||||
module.exports = function (server, auth) {
|
||||
server.post('/installs', auth.basic, (req, res, next) => {
|
||||
|
||||
let data = req.body || {};
|
||||
|
||||
@@ -20,7 +20,7 @@ module.exports = function(server) {
|
||||
});
|
||||
});
|
||||
|
||||
server.get('/installs', (req, res, next) => {
|
||||
server.get('/installs', auth.manager, (req, res, next) => {
|
||||
Install.apiQuery(req.params, function(err, docs) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
@@ -34,7 +34,7 @@ module.exports = function(server) {
|
||||
});
|
||||
});
|
||||
|
||||
server.get('/installs/:install_id', (req, res, next) => {
|
||||
server.get('/installs/:install_id', auth.manager, (req, res, next) => {
|
||||
Install.findOne({ _id: req.params.install_id }, function(err, doc) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
@@ -48,7 +48,7 @@ module.exports = function(server) {
|
||||
});
|
||||
});
|
||||
|
||||
server.put('/installs/:install_id', (req, res, next) => {
|
||||
server.put('/installs/:install_id', auth.manager, (req, res, next) => {
|
||||
|
||||
let data = req.body || {};
|
||||
|
||||
@@ -70,7 +70,7 @@ module.exports = function(server) {
|
||||
);
|
||||
}
|
||||
|
||||
Install.update({ _id: data._id }, data, function(err) {
|
||||
Install.updateOne({ _id: data._id }, data, function(err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return next(
|
||||
@@ -84,7 +84,7 @@ module.exports = function(server) {
|
||||
});
|
||||
});
|
||||
|
||||
server.del('/installs/:install_id', (req, res, next) => {
|
||||
server.del('/installs/:install_id', auth.manager, (req, res, next) => {
|
||||
Install.deleteOne({ _id: req.params.install_id }, function(err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
|
||||
Reference in New Issue
Block a user