node.js DDP クライアント ( node-ddpinsertMessage
を使用) は、ドキュメントを mongodb に保存する DDP サーバー上のメソッドを呼び出します。
Meteor.methods({
'insertMessage': function(msg) {
Messages.insert({'msg':msg, 'userId': userId})
}
})
userId
認証された DDP クライアントのみが、一意の識別子 を含むドキュメントを挿入できるようにし、他の誰かの を偽造できないようにするにはどうすればよいuserId
でしょうか? ddp-loginを見ましたが、認証が成功するとトークンが生成されるようです。このトークンを目的に使用できますか?
Meteor.methods({
'insertMessage': function(msg) {
// Check that the current user's userId (how can we do this?)
userId = getUserId()
Messages.insert({'msg':msg, 'userId': userId})
}
})