我正在尝试通知用户该文档已存在,但用户无权查看该文档。
从发布函数抛出Meteor.Error不起作用。
Meteor.publish "projectWithStories", (projectId) ->
check projectId, String
project = Projects.findOne projectId
# return nothing if there is no project with this id
unless project then return @ready()
# check if the user has rights
if documentAuthorOrAddedUser @userId, project
[
Projects.find projectId
Stories.find projectId: projectId
]
else
@ready()
# this does not work =//
# without this i'm getting 'dataNotFound' that is not valid
throw new Meteor.Error 403, "Not allowed"
我也在使用铁路由器和'dataNotFound'钩子
============================= EDIT ================= ===============
好的,我找到了解决方案!
将最后一行代码更改为魅力
if
.....
.....
else
@error throw new Meteor.Error(403, "Not allowed")