0

尝试使用流星角更新用户的个人资料时,我得到了 403。不幸的是,它的描述性不是很好——完整的错误是:

{ 
  details: undefined
  error: 403
  errorType: "Meteor.Error"
  message: "Access denied [403]"
  reason: "Access denied"
}

我的印象是我不需要向服务器端添加任何内容,但我添加是为了尝试了解实际更新请求的外观。

Meteor.users.deny {
  update: (userId, user, fields, modifier) ->
    console.log("meteor deny!")
    console.log(userId, user._id)
    console.log(fields, modifier)
    false
}

Meteor.users.allow {
  update: (userId, user, fields, modifier) ->
    console.log("allow", arguments)
    true
}

用于调试。在日志中,我看到

I20150707-22:14:22.955(-6)?流星否认!
I20150707-22:14:22.956(-6)?Hk83p9hieEBYHhzo6 Hk83p9hieEBYHhzo6
I20150707-22:14:22.956(-6)?[ 'profile' ] { '$set': { 'profile.name': 'ben', 'profile.gender': 'male' } }

这正是我希望看到的,并且似乎是查看文档时所需要的——即用户正在编辑他们自己的个人资料,而 $set 正在使用点表示法。我正在从客户端触发更新,基本上使用非常简单的角度。有趣的是

....
$scope.user = $meteor.object $meteor.getCollectionByName("users"), $stateParams.userId
$scope.save = () ->
  if $scope.form.$valid
    $scope.user.save({ 'profile.name': $scope.user.profile.name, 'profile.gender': $scope.user.profile.gender}).then(
      (numberOfDocs) ->
        console.log 'save successful, docs affected ', numberOfDocs
      (error) ->
        console.log 'save error ', error
    )

我有点不知所措,不知道下一步该尝试什么。我的包裹是

meteor-platform
urigo:angular
angularui:angular-ui-router
coffeescript
mquandalle:stylus
civilframe:angular-jade
twbs:bootstrap
angularui:angular-ui-bootstrap
mquandalle:bower
tmeasday:publish-counts
aldeed:collection2
angularutils:pagination
accounts-ui
okland:accounts-phone
accounts-base
4

1 回答 1

0

不是一个完整的答案,但要立即解决您的问题,只需创建一个更新用户配置文件服务器端的方法。只需检查用户是否只是试图编辑他自己的个人资料。

于 2015-07-08T08:11:18.423 回答