mirror of
https://github.com/Infisical/infisical.git
synced 2026-01-09 07:28:09 -05:00
fix: correct membership update constraints
This commit is contained in:
@@ -58,6 +58,10 @@ export const additionalPrivilegeServiceFactory = ({
|
||||
const scope = factory.getScopeField(dto.scopeData);
|
||||
const dbActorField = data.actorType === ActorType.IDENTITY ? "actorIdentityId" : "actorUserId";
|
||||
|
||||
if (dto.data.actorId === dto.permission.id) {
|
||||
throw new BadRequestError({ message: "Cannot assign additional privileges to your own membership" });
|
||||
}
|
||||
|
||||
const existingSlug = await additionalPrivilegeDAL.findOne({
|
||||
name: data.name,
|
||||
[dbActorField]: data.actorId,
|
||||
@@ -120,6 +124,10 @@ export const additionalPrivilegeServiceFactory = ({
|
||||
const scope = factory.getScopeField(dto.scopeData);
|
||||
const dbActorField = dto.selector.actorType === ActorType.IDENTITY ? "actorIdentityId" : "actorUserId";
|
||||
|
||||
if (dto.selector.actorId === dto.permission.id) {
|
||||
throw new BadRequestError({ message: "Cannot update additional privileges on your own membership" });
|
||||
}
|
||||
|
||||
const existingPrivilege = await additionalPrivilegeDAL.findOne({
|
||||
[dbActorField]: dto.selector.actorId,
|
||||
id: dto.selector.id,
|
||||
@@ -181,6 +189,10 @@ export const additionalPrivilegeServiceFactory = ({
|
||||
const scope = factory.getScopeField(dto.scopeData);
|
||||
const dbActorField = dto.selector.actorType === ActorType.IDENTITY ? "actorIdentityId" : "actorUserId";
|
||||
|
||||
if (dto.selector.actorId === dto.permission.id) {
|
||||
throw new BadRequestError({ message: "Cannot remove additional privileges from your own membership" });
|
||||
}
|
||||
|
||||
const existingPrivilege = await additionalPrivilegeDAL.findOne({
|
||||
id: selector.id,
|
||||
[dbActorField]: dto.selector.actorId,
|
||||
|
||||
@@ -203,6 +203,11 @@ export const membershipIdentityServiceFactory = ({
|
||||
message: "Identity doesn't have membership"
|
||||
});
|
||||
|
||||
if (existingMembership.actorIdentityId === dto.permission.id)
|
||||
throw new BadRequestError({
|
||||
message: "You can't update your own membership"
|
||||
});
|
||||
|
||||
const scopeField = factory.getScopeField(dto.scopeData);
|
||||
const customRoles = hasCustomRole
|
||||
? await roleDAL.find({
|
||||
|
||||
@@ -326,6 +326,11 @@ export const membershipUserServiceFactory = ({
|
||||
message: "User doesn't have membership"
|
||||
});
|
||||
|
||||
if (existingMembership.actorUserId === dto.permission.id)
|
||||
throw new BadRequestError({
|
||||
message: "You can't update your own membership"
|
||||
});
|
||||
|
||||
const scopeField = factory.getScopeField(dto.scopeData);
|
||||
const customRoles = hasCustomRole
|
||||
? await roleDAL.find({
|
||||
|
||||
Reference in New Issue
Block a user