Skip to content

Commit 16257a7

Browse files
committed
fix: permission grants in open_item
1 parent bfacfc2 commit 16257a7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/backend/src/routers/open_item.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ module.exports = eggspress('/open_item', {
8484
// Note: We always grant write permission here. If the user only
8585
// has read permission this is still safe; user permissions
8686
// are always checked during an app access.
87-
const permission = `fs:${subject.uid}:write`;
88-
const svc_permission = Context.get('services').get('permission');
89-
await svc_permission.grant_user_app_permission(
90-
actor, app.uid, permission, {}, { reason: 'open_item' }
91-
);
87+
const PERMS = action === 'write' ? ['read', 'write'] : ['read'];
88+
for ( const perm of PERMS ) {
89+
const permission = `fs:${subject.uid}:${perm}`;
90+
const svc_permission = Context.get('services').get('permission');
91+
await svc_permission.grant_user_app_permission(
92+
actor, app.uid, permission, {}, { reason: 'open_item' }
93+
);
94+
}
9295

9396
// Generate user-app token
9497
const svc_auth = Context.get('services').get('auth');

0 commit comments

Comments
 (0)