2017-05-29 33 views
0

我想了一个名为profile属性添加到用户模式:回环ACL用户的财产

var User = app.models.User; 
    User.profile = function(cb) { 
     cb(null, "TEST"); 
    } 

    User.remoteMethod('profile', { 
     accepts: [ 
     {arg: 'id', type: 'number', required: true} 
      ], 
     returns: {arg: 'id', type: 'string'}, 
     http: {path: '/:id/profile', verb: 'get'} 
    }); 

然后我说这个ACL:

var ACL = app.models.ACL; 
    ACL.create({ 
    model: 'user', 
    accessType: 'EXECUTE', 
    principalType: 'ROLE', 
    principalId: '$owner', 
    permission: 'ALLOW', 
    property: 'profile' 
    }, function (err, acl) { 
    console.log('ACL entry created: %j', acl); 
    }); 

当我去这个网址:http://localhost:3000/api/users/2/profile,它返回Error: Custom message: Authorization Required。 access_token是正确的,因为当我去http://localhost:3000/api/users/2/它返回正确的数据。 我错过了什么?

回答

0

想通了,它需要是User而不是user