11var _ = require ( 'underscore' ) ;
22
33module . exports = function ( AV ) {
4- var PUBLIC_KEY = "*" ;
4+ var PUBLIC_KEY = '*' ;
55
66 /**
77 * Creates a new ACL.
@@ -26,19 +26,25 @@ module.exports = function(AV) {
2626 self . setWriteAccess ( arg1 , true ) ;
2727 } else {
2828 if ( _ . isFunction ( arg1 ) ) {
29- throw new Error ( 'AV.ACL() called with a function. Did you forget ()?' ) ;
29+ throw new Error (
30+ 'AV.ACL() called with a function. Did you forget ()?'
31+ ) ;
3032 }
3133 AV . _objectEach ( arg1 , function ( accessList , userId ) {
3234 if ( ! _ . isString ( userId ) ) {
3335 throw new Error ( 'Tried to create an ACL with an invalid userId.' ) ;
3436 }
3537 self . permissionsById [ userId ] = { } ;
3638 AV . _objectEach ( accessList , function ( allowed , permission ) {
37- if ( permission !== "read" && permission !== "write" ) {
38- throw new Error ( 'Tried to create an ACL with an invalid permission type.' ) ;
39+ if ( permission !== 'read' && permission !== 'write' ) {
40+ throw new Error (
41+ 'Tried to create an ACL with an invalid permission type.'
42+ ) ;
3943 }
4044 if ( ! _ . isBoolean ( allowed ) ) {
41- throw new Error ( 'Tried to create an ACL with an invalid permission value.' ) ;
45+ throw new Error (
46+ 'Tried to create an ACL with an invalid permission value.'
47+ ) ;
4248 }
4349 self . permissionsById [ userId ] [ permission ] = allowed ;
4450 } ) ;
@@ -59,7 +65,7 @@ module.exports = function(AV) {
5965 if ( userId instanceof AV . User ) {
6066 userId = userId . id ;
6167 } else if ( userId instanceof AV . Role ) {
62- userId = " role:" + userId . getName ( ) ;
68+ userId = ' role:' + userId . getName ( ) ;
6369 }
6470 if ( ! _ . isString ( userId ) ) {
6571 throw new Error ( 'userId must be a string.' ) ;
@@ -92,7 +98,7 @@ module.exports = function(AV) {
9298 if ( userId instanceof AV . User ) {
9399 userId = userId . id ;
94100 } else if ( userId instanceof AV . Role ) {
95- userId = " role:" + userId . getName ( ) ;
101+ userId = ' role:' + userId . getName ( ) ;
96102 }
97103 var permissions = this . permissionsById [ userId ] ;
98104 if ( ! permissions ) {
@@ -107,7 +113,7 @@ module.exports = function(AV) {
107113 * @param {Boolean } allowed Whether that user should have read access.
108114 */
109115 AV . ACL . prototype . setReadAccess = function ( userId , allowed ) {
110- this . _setAccess ( " read" , userId , allowed ) ;
116+ this . _setAccess ( ' read' , userId , allowed ) ;
111117 } ;
112118
113119 /**
@@ -119,7 +125,7 @@ module.exports = function(AV) {
119125 * @return {Boolean }
120126 */
121127 AV . ACL . prototype . getReadAccess = function ( userId ) {
122- return this . _getAccess ( " read" , userId ) ;
128+ return this . _getAccess ( ' read' , userId ) ;
123129 } ;
124130
125131 /**
@@ -128,7 +134,7 @@ module.exports = function(AV) {
128134 * @param {Boolean } allowed Whether that user should have write access.
129135 */
130136 AV . ACL . prototype . setWriteAccess = function ( userId , allowed ) {
131- this . _setAccess ( " write" , userId , allowed ) ;
137+ this . _setAccess ( ' write' , userId , allowed ) ;
132138 } ;
133139
134140 /**
@@ -140,7 +146,7 @@ module.exports = function(AV) {
140146 * @return {Boolean }
141147 */
142148 AV . ACL . prototype . getWriteAccess = function ( userId ) {
143- return this . _getAccess ( " write" , userId ) ;
149+ return this . _getAccess ( ' write' , userId ) ;
144150 } ;
145151
146152 /**
@@ -190,7 +196,7 @@ module.exports = function(AV) {
190196 role = role . getName ( ) ;
191197 }
192198 if ( _ . isString ( role ) ) {
193- return this . getReadAccess ( " role:" + role ) ;
199+ return this . getReadAccess ( ' role:' + role ) ;
194200 }
195201 throw new Error ( 'role must be a AV.Role or a String' ) ;
196202 } ;
@@ -210,7 +216,7 @@ module.exports = function(AV) {
210216 role = role . getName ( ) ;
211217 }
212218 if ( _ . isString ( role ) ) {
213- return this . getWriteAccess ( " role:" + role ) ;
219+ return this . getWriteAccess ( ' role:' + role ) ;
214220 }
215221 throw new Error ( 'role must be a AV.Role or a String' ) ;
216222 } ;
@@ -229,7 +235,7 @@ module.exports = function(AV) {
229235 role = role . getName ( ) ;
230236 }
231237 if ( _ . isString ( role ) ) {
232- this . setReadAccess ( " role:" + role , allowed ) ;
238+ this . setReadAccess ( ' role:' + role , allowed ) ;
233239 return ;
234240 }
235241 throw new Error ( 'role must be a AV.Role or a String' ) ;
@@ -249,10 +255,9 @@ module.exports = function(AV) {
249255 role = role . getName ( ) ;
250256 }
251257 if ( _ . isString ( role ) ) {
252- this . setWriteAccess ( " role:" + role , allowed ) ;
258+ this . setWriteAccess ( ' role:' + role , allowed ) ;
253259 return ;
254260 }
255261 throw new Error ( 'role must be a AV.Role or a String' ) ;
256262 } ;
257-
258263} ;
0 commit comments