Files
outline/server/policies/team.ts
T
Tom Moor a40198a97d feat: Add expiry dates for public share links (#14513)
* wip

* fix: Treat null expiresAt as no expiry when creating a share

* fix: Add bottom padding to share notices
2026-11-09 22:29:49 -05:00

87 lines
1.6 KiB
TypeScript

import { PlanFeature } from "@shared/types";
import { Team, User } from "@server/models";
import { allow } from "./cancan";
import {
and,
isCloudHosted,
isTeamAdmin,
isTeamModel,
isTeamMutable,
or,
teamHasEntitlement,
} 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(),
isTeamModel(actor, team),
!actor.isGuest,
!actor.isViewer,
or(actor.isAdmin, !!team?.memberTeamCreate)
)
);
allow(User, "update", Team, isTeamAdmin);
allow(User, "delete", Team, (actor, team) =>
and(
//
isCloudHosted(),
isTeamAdmin(actor, team)
)
);
allow(User, "audit", Team, (actor, team) =>
and(
//
isTeamAdmin(actor, team),
teamHasEntitlement(team, PlanFeature.AuditLog)
)
);
allow(User, "externalGroupSync", Team, (actor, team) =>
and(
//
isTeamAdmin(actor, team),
teamHasEntitlement(team, PlanFeature.GroupSync)
)
);
allow(User, "setDefaultShareExpiry", Team, (actor, team) =>
and(
//
isTeamAdmin(actor, team),
teamHasEntitlement(team, PlanFeature.AdvancedSecurity)
)
);
allow(User, ["createTemplate", "updateTemplate"], Team, (actor, team) =>
and(
//
actor.isAdmin,
isTeamModel(actor, team),
isTeamMutable(actor)
)
);