This repository has been archived on 2022-08-14. You can view files and clone it, but cannot push or open issues or pull requests.
outline/server/policies/share.js

16 lines
517 B
JavaScript

// @flow
import policy from './policy';
import { Share, User } from '../models';
import { AdminRequiredError } from '../errors';
const { allow } = policy;
allow(User, ['read'], Share, (user, share) => user.teamId === share.teamId);
allow(User, ['update'], Share, (user, share) => false);
allow(User, ['delete'], Share, (user, share) => {
if (!share || user.teamId !== share.teamId) return false;
if (user.id === share.userId) return false;
if (user.isAdmin) return true;
throw new AdminRequiredError();
});