33// This file is licensed under the MIT License.
44// License text available at https://opensource.org/licenses/MIT
55
6+ 'use strict' ;
67/*!
78 Schema ACL options
8-
99 Object level permissions, for example, an album owned by a user
10-
1110 Factors to be authorized against:
12-
1311 * model name: Album
1412 * model instance properties: userId of the album, friends, shared
1513 * methods
2119 ** none
2220 ** everyone
2321 ** relations: owner/friend/granted
24-
2522 Class level permissions, for example, Album
2623 * model name: Album
2724 * methods
28-
2925 URL/Route level permissions
3026 * url pattern
3127 * application id
3228 * ip addresses
3329 * http headers
34-
3530 Map to oAuth 2.0 scopes
36-
3731 */
3832
3933var g = require ( '../../lib/globalize' ) ;
@@ -331,10 +325,10 @@ module.exports = function(ACL) {
331325 principalId = principalId . toString ( ) ;
332326 }
333327 property = property || ACL . ALL ;
334- var propertyQuery = ( property === ACL . ALL ) ? undefined : { inq : [ property , ACL . ALL ] } ;
328+ var propertyQuery = ( property === ACL . ALL ) ? undefined : { inq : [ property , ACL . ALL ] } ;
335329 accessType = accessType || ACL . ALL ;
336330 var accessTypeQuery = ( accessType === ACL . ALL ) ? undefined :
337- { inq : [ accessType , ACL . ALL , ACL . EXECUTE ] } ;
331+ { inq : [ accessType , ACL . ALL , ACL . EXECUTE ] } ;
338332
339333 var req = new AccessRequest ( model , property , accessType ) ;
340334
@@ -352,8 +346,8 @@ module.exports = function(ACL) {
352346 }
353347
354348 var self = this ;
355- this . find ( { where : { principalType : principalType , principalId : principalId ,
356- model : model , property : propertyQuery , accessType : accessTypeQuery } } ,
349+ this . find ( { where : { principalType : principalType , principalId : principalId ,
350+ model : model , property : propertyQuery , accessType : accessTypeQuery } } ,
357351 function ( err , dynACLs ) {
358352 if ( err ) {
359353 if ( callback ) callback ( err ) ;
@@ -408,21 +402,21 @@ module.exports = function(ACL) {
408402 var modelName = context . modelName ;
409403
410404 var methodNames = context . methodNames ;
411- var propertyQuery = ( property === ACL . ALL ) ? undefined : { inq : methodNames . concat ( [ ACL . ALL ] ) } ;
405+ var propertyQuery = ( property === ACL . ALL ) ? undefined : { inq : methodNames . concat ( [ ACL . ALL ] ) } ;
412406
413407 var accessTypeQuery = ( accessType === ACL . ALL ) ?
414408 undefined :
415409 ( accessType === ACL . REPLICATE ) ?
416- { inq : [ ACL . REPLICATE , ACL . WRITE , ACL . ALL ] } :
417- { inq : [ accessType , ACL . ALL ] } ;
410+ { inq : [ ACL . REPLICATE , ACL . WRITE , ACL . ALL ] } :
411+ { inq : [ accessType , ACL . ALL ] } ;
418412
419413 var req = new AccessRequest ( modelName , property , accessType , ACL . DEFAULT , methodNames ) ;
420414
421415 var effectiveACLs = [ ] ;
422416 var staticACLs = self . getStaticACLs ( model . modelName , property ) ;
423417
424- this . find ( { where : { model : model . modelName , property : propertyQuery ,
425- accessType : accessTypeQuery } } , function ( err , acls ) {
418+ this . find ( { where : { model : model . modelName , property : propertyQuery ,
419+ accessType : accessTypeQuery } } , function ( err , acls ) {
426420 if ( err ) {
427421 if ( callback ) callback ( err ) ;
428422 return ;
@@ -525,15 +519,15 @@ module.exports = function(ACL) {
525519 this . resolveRelatedModels ( ) ;
526520 switch ( type ) {
527521 case ACL . ROLE :
528- this . roleModel . findOne ( { where : { or : [ { name : id } , { id : id } ] } } , cb ) ;
522+ this . roleModel . findOne ( { where : { or : [ { name : id } , { id : id } ] } } , cb ) ;
529523 break ;
530524 case ACL . USER :
531525 this . userModel . findOne (
532- { where : { or : [ { username : id } , { email : id } , { id : id } ] } } , cb ) ;
526+ { where : { or : [ { username : id } , { email : id } , { id : id } ] } } , cb ) ;
533527 break ;
534528 case ACL . APP :
535529 this . applicationModel . findOne (
536- { where : { or : [ { name : id } , { email : id } , { id : id } ] } } , cb ) ;
530+ { where : { or : [ { name : id } , { email : id } , { id : id } ] } } , cb ) ;
537531 break ;
538532 default :
539533 process . nextTick ( function ( ) {
0 commit comments