Files
outline/server/policies/collection.js
Tom Moor 83f32be6f7 Add missing authorization on views endpoints
Updated ApiKeys authorization to match elsewhere
2018-02-18 10:56:56 -08:00

25 lines
459 B
JavaScript

// @flow
import policy from './policy';
import { Collection, User } from '../models';
const { allow } = policy;
allow(User, 'create', Collection);
allow(
User,
['read', 'update'],
Collection,
(user, collection) => collection && user.teamId === collection.teamId
);
allow(
User,
'delete',
Collection,
(user, collection) =>
collection &&
user.teamId === collection.teamId &&
(user.id === collection.creatorId || user.isAdmin)
);