misc: finalized error message

This commit is contained in:
Sheen Capadngan
2025-03-21 18:48:02 +08:00
parent cca7b68dd0
commit 6f9a66a0d7
8 changed files with 13 additions and 11 deletions

View File

@@ -100,7 +100,7 @@ export const groupServiceFactory = ({
throw new ForbiddenRequestError({
name: "PermissionBoundaryError",
message: constructPermissionErrorMessage(
"Failed to create a more privileged group",
"Failed to create group",
membership.shouldUseNewPrivilegeSystem,
OrgPermissionGroupActions.ManagePrivileges,
OrgPermissionSubjects.Groups
@@ -185,7 +185,7 @@ export const groupServiceFactory = ({
throw new ForbiddenRequestError({
name: "PermissionBoundaryError",
message: constructPermissionErrorMessage(
"Failed to update a more privileged group",
"Failed to update group",
membership.shouldUseNewPrivilegeSystem,
OrgPermissionGroupActions.ManagePrivileges,
OrgPermissionSubjects.Groups

View File

@@ -188,7 +188,9 @@ const constructPermissionErrorMessage = (
opSubject: OrgPermissionSet[1] | ProjectPermissionSet[1]
) => {
return `${baseMessage}${
shouldUseNewPrivilegeSystem ? `. Missing permission ${opAction as string} on ${opSubject as string}` : ""
shouldUseNewPrivilegeSystem
? `. Missing permission ${opAction as string} on ${opSubject as string}`
: ". Privilege level is not high enough to perform this action"
}`;
};

View File

@@ -116,7 +116,7 @@ export const groupProjectServiceFactory = ({
throw new ForbiddenRequestError({
name: "PermissionBoundaryError",
message: constructPermissionErrorMessage(
"Failed to assign group to a more privileged role",
"Failed to assign group to role",
membership.shouldUseNewPrivilegeSystem,
ProjectPermissionGroupActions.ManagePrivileges,
ProjectPermissionSub.Groups
@@ -294,7 +294,7 @@ export const groupProjectServiceFactory = ({
throw new ForbiddenRequestError({
name: "PermissionBoundaryError",
message: constructPermissionErrorMessage(
"Failed to assign group to a more privileged role",
"Failed to assign group to role",
membership.shouldUseNewPrivilegeSystem,
ProjectPermissionGroupActions.ManagePrivileges,
ProjectPermissionSub.Groups

View File

@@ -104,7 +104,7 @@ export const identityProjectServiceFactory = ({
throw new ForbiddenRequestError({
name: "PermissionBoundaryError",
message: constructPermissionErrorMessage(
"Failed to assign to a more privileged role",
"Failed to assign to role",
membership.shouldUseNewPrivilegeSystem,
ProjectPermissionIdentityActions.ManagePrivileges,
ProjectPermissionSub.Identity
@@ -212,7 +212,7 @@ export const identityProjectServiceFactory = ({
throw new ForbiddenRequestError({
name: "PermissionBoundaryError",
message: constructPermissionErrorMessage(
"Failed to change to a more privileged role",
"Failed to change role",
membership.shouldUseNewPrivilegeSystem,
ProjectPermissionIdentityActions.ManagePrivileges,
ProjectPermissionSub.Identity

View File

@@ -446,7 +446,7 @@ export const identityUaServiceFactory = ({
throw new ForbiddenRequestError({
name: "PermissionBoundaryError",
message: constructPermissionErrorMessage(
"Failed to create client secret for a more privileged identity.",
"Failed to create client secret for identity.",
membership.shouldUseNewPrivilegeSystem,
OrgPermissionIdentityActions.CreateToken,
OrgPermissionSubjects.Identity

View File

@@ -78,7 +78,7 @@ export const identityServiceFactory = ({
throw new ForbiddenRequestError({
name: "PermissionBoundaryError",
message: constructPermissionErrorMessage(
"Failed to create a more privileged identity",
"Failed to create identity",
membership.shouldUseNewPrivilegeSystem,
OrgPermissionIdentityActions.ManagePrivileges,
OrgPermissionSubjects.Identity

View File

@@ -951,7 +951,7 @@ export const orgServiceFactory = ({
throw new ForbiddenRequestError({
name: "PermissionBoundaryError",
message: constructPermissionErrorMessage(
"Failed to invite user to a more privileged role in the project",
"Failed to invite user to the project",
membership.shouldUseNewPrivilegeSystem,
ProjectPermissionMemberActions.ManagePrivileges,
ProjectPermissionSub.Member

View File

@@ -288,7 +288,7 @@ export const projectMembershipServiceFactory = ({
throw new ForbiddenRequestError({
name: "PermissionBoundaryError",
message: constructPermissionErrorMessage(
`Failed to change to a more privileged role ${requestedRoleChange}`,
`Failed to change role ${requestedRoleChange}`,
membership.shouldUseNewPrivilegeSystem,
ProjectPermissionMemberActions.ManagePrivileges,
ProjectPermissionSub.Member