【发布时间】:2014-02-16 00:27:54
【问题描述】:
有以下政策:
// file: api/policies/foo.js
module.exports = function(req, res, next) {
Model.find().done(function(err, result) {
if (result.length > 5) {
return res.forbidden();
} else {
return next();
}
});
};
// file: config/policies.js
module.exports.policies = {
ModelController: {
'find': 'foo'
}
};
以及默认的Model 和ModelController。我现在在两个客户端上执行以下操作:
// client 1
socket.get('/model', function(result) { console.log(result) });
// client 2
var i = 10;
while (i--) { socket.post('/model', { foo: 'bar' }); }
客户端 1 实际上接收了 10 个更新,尽管他只被允许接收 5 个。
通过socket.get 重新连接时,出现相应的权限错误。
我的问题: 在通过套接字发送更新之前检查权限的最佳做法是什么?
【问题讨论】: