made req.oauth3 immutable after its creation
This commit is contained in:
parent
de594964b4
commit
92d052faf0
|
@ -165,6 +165,15 @@ function verifyToken(token) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deepFreeze(obj) {
|
||||||
|
Object.keys(obj).forEach(function (key) {
|
||||||
|
if (obj[key] && typeof obj[key] === 'object') {
|
||||||
|
deepFreeze(obj[key]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Object.freeze(obj);
|
||||||
|
}
|
||||||
|
|
||||||
function attachOauth3(req, res, next) {
|
function attachOauth3(req, res, next) {
|
||||||
req.oauth3 = {};
|
req.oauth3 = {};
|
||||||
|
|
||||||
|
@ -210,6 +219,8 @@ function attachOauth3(req, res, next) {
|
||||||
return PromiseA.resolve(sub || ppid);
|
return PromiseA.resolve(sub || ppid);
|
||||||
};
|
};
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
|
deepFreeze(req.oauth3);
|
||||||
|
Object.defineProperty(req, 'oauth3', {configurable: false, writable: false});
|
||||||
next();
|
next();
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
res.send(err);
|
res.send(err);
|
||||||
|
|
Loading…
Reference in New Issue