Add MembersCanCreateApiKey team preference

This commit is contained in:
Tom Moor
2024-06-05 08:30:30 -04:00
parent cf16d25a67
commit 025ee63f0b
5 changed files with 12 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
import { TeamPreference } from "@shared/types";
import { ApiKey, User, Team } from "@server/models";
import { allow } from "./cancan";
import { and, isOwner, isTeamModel, isTeamMutable } from "./utils";
@@ -9,7 +10,9 @@ allow(User, "createApiKey", Team, (actor, team) =>
isTeamMutable(actor),
!actor.isViewer,
!actor.isGuest,
!actor.isSuspended
!actor.isSuspended,
actor.isAdmin ||
!!team?.getPreference(TeamPreference.MembersCanCreateApiKey)
)
);