fix: Single share record per document (#1984)

This commit is contained in:
Tom Moor
2021-03-24 18:28:38 -07:00
committed by GitHub
parent 877c01f723
commit 46912f8ddb
3 changed files with 36 additions and 7 deletions

View File

@ -5,8 +5,14 @@ import policy from "./policy";
const { allow } = policy;
allow(User, ["read"], Share, (user, share) => user.teamId === share.teamId);
allow(User, ["update", "revoke"], Share, (user, share) => {
allow(
User,
["read", "update"],
Share,
(user, share) => user.teamId === share.teamId
);
allow(User, "revoke", Share, (user, share) => {
if (!share || user.teamId !== share.teamId) return false;
if (user.id === share.userId) return true;
if (user.isAdmin) return true;