2017-05-29 3 views
0

I profile zu User-Modell namens eine Eigenschaft hinzufügen möchten:Loopback acl Benutzerhandbuch Eigenschaft

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'} 
    }); 

Dann habe ich diese 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); 
    }); 

Wenn ich auf diese URL: http://localhost:3000/api/users/2/profile, es gibt Error: Custom message: Authorization Required zurück. Das access_token ist korrekt, denn wenn ich zu http://localhost:3000/api/users/2/ gehe, gibt es mir korrekte Daten zurück. Was vermisse ich?

Antwort

0

schaut hat, braucht es User statt user

zu sein