Collection Permissions (#829)

see https://github.com/outline/outline/issues/668
This commit is contained in:
Tom Moor
2019-01-05 13:37:33 -08:00
committed by GitHub
parent 8978915423
commit 8c02b0028c
53 changed files with 1379 additions and 214 deletions

View File

@ -2,7 +2,7 @@
import policy from './policy';
import { Document, Revision, User } from '../models';
const { allow } = policy;
const { allow, authorize } = policy;
allow(User, 'create', Document);
@ -10,7 +10,13 @@ allow(
User,
['read', 'update', 'delete', 'share'],
Document,
(user, document) => user.teamId === document.teamId
(user, document) => {
if (document.collection) {
authorize(user, 'read', document.collection);
}
return user.teamId === document.teamId;
}
);
allow(