Files
outline/server/policies/team.js
Tom Moor fb4f6822a4 feat: Events / audit log (#1008)
* feat: Record events in DB

* feat: events API

* First pass, hacky activity feed

* WIP

* Reset dashboard

* feat: audit log UI
feat: store ip address

* chore: Document events.list api

* fix: command specs

* await event create

* fix: backlinks service

* tidy

* fix: Hide audit log menu item if not admin
2019-08-05 20:38:31 -07:00

25 lines
637 B
JavaScript

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