【问题标题】:403 Unauthorized when updating Meteor User更新 Meteor 用户时出现 403 Unauthorized
【发布时间】:2015-09-25 19:46:10
【问题描述】:

我在尝试使用流星角更新用户个人资料时收到 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

【问题讨论】:

  • 摆脱deny而只使用allow是否有效?
  • 否定。即使我删除了拒绝,我也从未在允许中看到日志语句

标签: angularjs meteor angular-meteor


【解决方案1】:

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

【讨论】:

  • 是的,我正在考虑这样做,但这似乎很愚蠢。我当然已经花了足够的时间来研究这一点,以保证这一点
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-10-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-28
  • 1970-01-01
  • 2016-11-29
相关资源
最近更新 更多