var ormDic = require('../../util/ormDic');

class OrmProxy {
    constructor() {
        this._orm = null;
    }

    setOrm(string) {
        this._orm = ormDic[string];
    }

    add(req, res) {
        if (req.headers.token === null || req.headers.token !== 'mps10') {
            var response = {};
            response.message = "Token inválido";
            response.token = req.headers.token || '';
            res.send(response);
        } else {
            this._orm.add(req, res);
        }
    }

    delete(req, res) {
        if (req.headers.token === null || req.headers.token !== 'mps10') {
            var response = {};
            response.message = "Token inválido";
            response.token = req.headers.token || '';
            res.send(response);
        } else {
            this._orm.delete(req, res);
        }
    }

    get(req, res) {
        this._orm.get(req, res);
    }

    getById(req, res) {
        this._orm.getById(req, res);
    }

    update(req, res) {
        if (req.headers.token === null || req.headers.token !== 'mps10') {
            var response = {};
            response.message = "Token inválido";
            response.token = req.headers.token || '';
            res.send(response);
        } else {
            this._orm.update(req, res);
        }

    }
}

module.exports = OrmProxy;
@@ -408,32 +408,44 @@
             res.
+status(401).
 send(response);%0A
@@ -755,32 +755,44 @@
             res.
+status(401).
 send(response);%0A
@@ -1241,16 +1241,28 @@
     res.
+status(401).
 send(res

Fix | Adicionando status code na validação do token