我正在使用 Meteor 帐户包。
假设我有使用 this.userId 做某事的 Meteor 方法。但是这些方法可以从任何客户端调用吗?这意味着恶意客户端可以在不登录的情况下调用这些方法?为了安全起见,我应该先手动检查客户端是否是登录用户吗?
export const myMethod = new ValidatedMethod({
name: 'myMethod',
validate: new SimpleSchema({
parameter: { type: String},
}).validator(),
run({ parameter }) {
//manually check if the user is logged in?
if(!this.userId) {
throw (new Meteor.Error("You have to be logged in"));
}
//do something here
}
});