mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
The results to render may come from an in-memory cache, or from the database. If they came from the in-memory cache, it's possible that obscurring the device field could actually change the values in memory. When obscurring, the device field, this patch copies all of the values in order to ensure that the in-memory copies are unaffected. With this patch, cached objects should not be affected.
16 lines
442 B
JavaScript
16 lines
442 B
JavaScript
var _ = require('lodash');
|
|
|
|
module.exports = function create_device_obscurity (env) {
|
|
function obscure_device (req, res, next) {
|
|
if (res.entries && env.settings.obscureDeviceProvenance) {
|
|
var entries = _.cloneDeep(res.entries);
|
|
for (var i = 0; i < entries.length; i++) {
|
|
entries[i].device = env.settings.obscureDeviceProvenance;
|
|
}
|
|
res.entries = entries;
|
|
}
|
|
next( );
|
|
}
|
|
return obscure_device;
|
|
}
|