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.
Files
outline/server/policies/share.js
Tom Moor ae502c10c9 Revoked share links (#664)
* Move to revokation API for share links

* Respect revoked share links
Add documentation for shares endpoints

* 💚
2018-06-16 12:36:25 -07:00

16 lines
516 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, ['revoke'], Share, (user, share) => {
if (!share || user.teamId !== share.teamId) return false;
if (user.id === share.userId) return true;
if (user.isAdmin) return true;
throw new AdminRequiredError();
});