mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
93509564e0
* Template management policies * PR feedback * fix: Should not be able to navigate to template edit screen Remove unused action Add 'New document from template' to template menu
60 lines
1.0 KiB
TypeScript
60 lines
1.0 KiB
TypeScript
import { Team, User } from "@server/models";
|
|
import { allow } from "./cancan";
|
|
import {
|
|
and,
|
|
isCloudHosted,
|
|
isTeamAdmin,
|
|
isTeamModel,
|
|
isTeamMutable,
|
|
or,
|
|
} from "./utils";
|
|
|
|
allow(User, "read", Team, isTeamModel);
|
|
|
|
allow(User, "readTemplate", Team, (actor, team) =>
|
|
and(
|
|
//
|
|
!actor.isGuest,
|
|
!actor.isViewer,
|
|
isTeamModel(actor, team)
|
|
)
|
|
);
|
|
|
|
allow(User, "share", Team, (actor, team) =>
|
|
and(
|
|
isTeamModel(actor, team),
|
|
!actor.isGuest,
|
|
!actor.isViewer,
|
|
!!team?.sharing
|
|
)
|
|
);
|
|
|
|
allow(User, "createTeam", Team, (actor, team) =>
|
|
and(
|
|
//
|
|
isCloudHosted(),
|
|
!actor.isGuest,
|
|
!actor.isViewer,
|
|
or(actor.isAdmin, !!team?.memberTeamCreate)
|
|
)
|
|
);
|
|
|
|
allow(User, "update", Team, isTeamAdmin);
|
|
|
|
allow(User, ["delete", "audit"], Team, (actor, team) =>
|
|
and(
|
|
//
|
|
isCloudHosted(),
|
|
isTeamAdmin(actor, team)
|
|
)
|
|
);
|
|
|
|
allow(User, ["createTemplate", "updateTemplate"], Team, (actor, team) =>
|
|
and(
|
|
//
|
|
actor.isAdmin,
|
|
isTeamModel(actor, team),
|
|
isTeamMutable(actor)
|
|
)
|
|
);
|