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)
)
);

View File

@@ -39,6 +39,8 @@ export const TeamsUpdateSchema = BaseSchema.extend({
viewersCanExport: z.boolean().optional(),
/** Whether members can invite new people to the team. */
membersCanInvite: z.boolean().optional(),
/** Whether members can create API keys. */
membersCanCreateApiKey: z.boolean().optional(),
/** Whether commenting is enabled */
commenting: z.boolean().optional(),
/** The custom theme for the team. */