Files
outline/server/policies/comment.ts
2023-03-11 19:08:12 -05:00

17 lines
385 B
TypeScript

import { Comment, User, Team } from "@server/models";
import { allow } from "./cancan";
allow(User, "createComment", Team, (user, team) => {
if (!team || user.teamId !== team.id) {
return false;
}
return true;
});
allow(User, ["read", "update", "delete"], Comment, (user, comment) => {
if (!comment) {
return false;
}
return user?.id === comment.createdById;
});