File tree 3 files changed +48
-11
lines changed
fixtures/simple-app/common/models
3 files changed +48
-11
lines changed Original file line number Diff line number Diff line change @@ -332,6 +332,12 @@ module.exports = class AccessUtils {
332
332
debug ( 'getCurrentGroupId context.remotingContext.args: %o' , context . remotingContext . args ) ;
333
333
let groupId = null ;
334
334
335
+ // If we are accessing the group model directly, the group id is the model id.
336
+ if ( this . isGroupModel ( context . model ) ) {
337
+ process . nextTick ( ( ) => cb ( null , context . modelId ) ) ;
338
+ return cb . promise ;
339
+ }
340
+
335
341
// If we are accessing an existing model, get the store id from the existing model instance.
336
342
// TODO: Cache this result so that it can be reused across each ACL lookup attempt.
337
343
if ( context . modelId ) {
Original file line number Diff line number Diff line change 45
45
{
46
46
"accessType" : " READ" ,
47
47
"principalType" : " ROLE" ,
48
- "principalId" : " admin" ,
49
- "permission" : " ALLOW" ,
50
- "property" : " find"
48
+ "principalId" : " $group:member" ,
49
+ "permission" : " ALLOW"
51
50
},
52
51
{
53
52
"accessType" : " READ" ,
54
53
"principalType" : " ROLE" ,
55
- "principalId" : " $group:member" ,
54
+ "principalId" : " $group:manager" ,
55
+ "permission" : " ALLOW"
56
+ },
57
+ {
58
+ "accessType" : " WRITE" ,
59
+ "principalType" : " ROLE" ,
60
+ "principalId" : " $group:manager" ,
56
61
"permission" : " ALLOW" ,
57
- "property" : " findById "
62
+ "property" : " create "
58
63
},
59
64
{
60
- "accessType" : " EXECUTE " ,
65
+ "accessType" : " WRITE " ,
61
66
"principalType" : " ROLE" ,
62
- "principalId" : " $authenticated " ,
67
+ "principalId" : " $group:manager " ,
63
68
"permission" : " ALLOW" ,
64
- "property" : " addUser "
69
+ "property" : " updateAttributes "
65
70
},
66
71
{
67
- "accessType" : " EXECUTE " ,
72
+ "accessType" : " WRITE " ,
68
73
"principalType" : " ROLE" ,
69
- "principalId" : " $authenticated " ,
74
+ "principalId" : " $group:manager " ,
70
75
"permission" : " ALLOW" ,
71
- "property" : " removeUser"
76
+ "property" : " upsert"
77
+ },
78
+ {
79
+ "accessType" : " *" ,
80
+ "principalType" : " ROLE" ,
81
+ "principalId" : " $group:admin" ,
82
+ "permission" : " ALLOW"
72
83
}
73
84
],
74
85
"methods" : {}
Original file line number Diff line number Diff line change @@ -64,6 +64,26 @@ describe('REST API', function() {
64
64
65
65
users . forEach ( user => {
66
66
describe ( `${ user . username } (User with ${ user . abilities . join ( ', ' ) } permissions):` , function ( ) {
67
+ // related group content
68
+ describe ( 'group model' , function ( ) {
69
+ if ( _includes ( user . abilities , 'read' ) ) {
70
+ it ( 'should get a teams store' , function ( ) {
71
+ return logInAs ( user . username )
72
+ . then ( res => json ( 'get' , `/api/stores/A?access_token=${ res . body . id } ` )
73
+ . expect ( 200 ) )
74
+ . then ( res => {
75
+ expect ( res . body ) . to . be . an ( 'object' ) ;
76
+ expect ( res . body ) . to . have . property ( 'name' , 'Store A' ) ;
77
+ } ) ;
78
+ } ) ;
79
+ }
80
+ it ( 'should not get another teams store' , function ( ) {
81
+ return logInAs ( user . username )
82
+ . then ( res => json ( 'get' , `/api/stores/B?access_token=${ res . body . id } ` )
83
+ . expect ( 401 ) ) ;
84
+ } ) ;
85
+ } ) ;
86
+
67
87
// related group content
68
88
describe ( 'related group content' , function ( ) {
69
89
if ( _includes ( user . abilities , 'read' ) ) {
You can’t perform that action at this time.
0 commit comments