17 lines
380 B
TypeScript
17 lines
380 B
TypeScript
import { NotificationSetting, Team, User } from "@server/models";
|
|
import { allow } from "./cancan";
|
|
|
|
allow(User, "createNotificationSetting", Team, (user, team) => {
|
|
if (!team || user.teamId !== team.id) {
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
|
|
allow(
|
|
User,
|
|
["read", "update", "delete"],
|
|
NotificationSetting,
|
|
(user, setting) => user && user.id === setting?.userId
|
|
);
|