Merge remote-tracking branch 'origin/main' into feat/moved-mfa-to-org-level

This commit is contained in:
Sheen Capadngan
2024-10-23 00:04:09 +08:00
128 changed files with 1889 additions and 953 deletions
+15 -10
View File
@@ -138,7 +138,7 @@ export const orgServiceFactory = ({
) => {
await permissionService.getUserOrgPermission(userId, orgId, actorAuthMethod, actorOrgId);
const org = await orgDAL.findOrgById(orgId);
if (!org) throw new NotFoundError({ message: "Organization not found" });
if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
return org;
};
/*
@@ -313,7 +313,7 @@ export const orgServiceFactory = ({
if (!samlCfg && !oidcCfg)
throw new NotFoundError({
message: "No enforceable SSO config found"
message: `SAML or OIDC configuration for organization with ID '${orgId}' not found`
});
}
@@ -335,7 +335,7 @@ export const orgServiceFactory = ({
defaultMembershipRole,
enforceMfa
});
if (!org) throw new NotFoundError({ message: "Organization not found" });
if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
return org;
};
/*
@@ -449,7 +449,8 @@ export const orgServiceFactory = ({
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Member);
const foundMembership = await orgMembershipDAL.findById(membershipId);
if (!foundMembership) throw new NotFoundError({ message: "Failed to find organization membership" });
if (!foundMembership)
throw new NotFoundError({ message: `Organization membership with ID ${membershipId} not found` });
if (foundMembership.orgId !== orgId)
throw new UnauthorizedError({ message: "Updated org member doesn't belong to the organization" });
if (foundMembership.userId === userId)
@@ -645,8 +646,12 @@ export const orgServiceFactory = ({
const orgRole = isCustomOrgRole ? OrgMembershipRole.Custom : organizationRoleSlug;
if (isCustomOrgRole) {
const customRole = await orgRoleDAL.findOne({ slug: organizationRoleSlug, orgId });
if (!customRole)
throw new NotFoundError({ name: "InviteUser", message: "Custom organization role not found" });
if (!customRole) {
throw new NotFoundError({
name: "InviteUser",
message: `Custom organization role with slug '${orgRole}' not found`
});
}
roleId = customRole.id;
}
@@ -804,7 +809,7 @@ export const orgServiceFactory = ({
if (!bot) {
throw new NotFoundError({
name: "InviteUser",
message: "Failed to find project bot"
message: `Failed to find project bot for project with ID '${projectId}'`
});
}
@@ -812,7 +817,7 @@ export const orgServiceFactory = ({
if (!ghostUserLatestKey) {
throw new NotFoundError({
name: "InviteUser",
message: "Failed to find project owner's latest key"
message: `Failed to find project owner's latest key for project with ID '${projectId}'`
});
}
@@ -1001,7 +1006,7 @@ export const orgServiceFactory = ({
const membership = await orgMembershipDAL.findOrgMembershipById(membershipId);
if (!membership) {
throw new NotFoundError({ message: "Organization membership not found" });
throw new NotFoundError({ message: `Organization membership with ID '${membershipId}' not found` });
}
if (membership.orgId !== orgId) {
throw new ForbiddenRequestError({ message: "Membership does not belong to organization" });
@@ -1047,7 +1052,7 @@ export const orgServiceFactory = ({
const membership = await orgMembershipDAL.findOrgMembershipById(orgMembershipId);
if (!membership) {
throw new NotFoundError({ message: "Organization membership not found" });
throw new NotFoundError({ message: `Organization membership with ID '${orgMembershipId}' not found` });
}
if (membership.orgId !== orgId) throw new NotFoundError({ message: "Failed to find organization membership" });