2015-07-03 18 views
1

我正在研究一個音樂應用程序,其類型爲&子類。 我們使用loopback作爲後端,angularJS作爲前端與cordova &離子。AngularJS JavaScript SDK(lb-service.js)&ACL:相關模型的屬性

我不能管理通過ACL授權,看起來像類型/請求:ID /體裁,爲此我必須通過LB-service.js自動進行一個proprety:Genre.subGenre()

關係的類型對於兩種模型都是「hasAndBelongsToMany」類型&子類型。

這裏是我的角度控制,我在前臺用做API請求:

$scope.genres = []; 

Genre.find().$promise.then(function(res) { //this request works : goes to GET /Genres endpoint 
    $scope.genres = res; 
    $scope.genres.forEach(function(genre) { 

    genre.checked=false; 
    genre.subgenres = []; 
    Genre.subGenres({id: genre.id}).$promise.then(function(r){ //it is this one that doesn't work, GET /Genres/:id/SubGenre endpoint 

     genre.subgenres = r; 
     genre.subgenres.forEach(function(s){ 
     s.checked=false; 
     }); 
    }); 
    }); 
}); 

這裏是LB-service.js提供的Genre.subGenre()屬性的代碼:

// INTERNAL. Use SubGenre.genres() instead. 
    "prototype$__get__genres": { 
     isArray: true, 
     url: urlBase + "/SubGenres/:id/genres", 
     method: "GET" 
    }, 

,這裏是在體裁模型)的代碼授權的存取權限的API爲Genre.subGenre(屬性:

"acls": [ 
    { 
    "accessType": "*", 
    "principalType": "ROLE", 
    "principalId": "$everyone", 
    "permission": "DENY" 
    }, 
    { 
    "accessType": "EXECUTE", 
    "principalType": "ROLE", 
    "principalId": "$authenticated", 
    "permission": "ALLOW", 
    "property": "subGenres" // this is to authorize Genre.subGenre(), doesn't works => 401 error. 
    }, 
    { 
    "accessType": "EXECUTE", 
    "principalType": "ROLE", 
    "principalId": "$authenticated", 
    "permission": "ALLOW", 
    "property": "find" // this is to authorize Genre.find(), it works 
    } 

它看起來像屬性是不正確的,因爲當我做同樣的事情來授權Genre.find()請求時,它是有效的。

非常感謝您的幫助。

回答

0

其實我想通了,我只需要在ACL改變:

"accessType": "EXECUTE" 

'"accessType": "READ"