mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Extra
This commit is contained in:
@@ -132,7 +132,7 @@ export const orgServiceFactory = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addGhostUser = async (orgId: string, tx?: Knex) => {
|
const addGhostUser = async (orgId: string, tx?: Knex) => {
|
||||||
const email = `ghost-${alphaNumericNanoId(16)}-${orgId}@infisical.com`; // We add a nanoid because the email is unique. And we have to create a new ghost user each time, so we can have access to the private key.
|
const email = `sudo-${alphaNumericNanoId(16)}-${orgId}@infisical.com`; // We add a nanoid because the email is unique. And we have to create a new ghost user each time, so we can have access to the private key.
|
||||||
const password = crypto.randomBytes(128).toString("hex");
|
const password = crypto.randomBytes(128).toString("hex");
|
||||||
|
|
||||||
const user = await userDAL.create(
|
const user = await userDAL.create(
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ForbiddenError } from "@casl/ability";
|
|||||||
import {
|
import {
|
||||||
OrgMembershipStatus,
|
OrgMembershipStatus,
|
||||||
ProjectMembershipRole,
|
ProjectMembershipRole,
|
||||||
|
ProjectVersion,
|
||||||
SecretKeyEncoding,
|
SecretKeyEncoding,
|
||||||
TableName,
|
TableName,
|
||||||
TProjectMemberships,
|
TProjectMemberships,
|
||||||
@@ -226,6 +227,10 @@ export const projectMembershipServiceFactory = ({
|
|||||||
const project = await projectDAL.findById(projectId);
|
const project = await projectDAL.findById(projectId);
|
||||||
if (!project) throw new BadRequestError({ message: "Project not found" });
|
if (!project) throw new BadRequestError({ message: "Project not found" });
|
||||||
|
|
||||||
|
if (project.version === ProjectVersion.V1) {
|
||||||
|
throw new BadRequestError({ message: "Please upgrade your project on your dashboard" });
|
||||||
|
}
|
||||||
|
|
||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Member);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Create, ProjectPermissionSub.Member);
|
||||||
|
|
||||||
@@ -243,7 +248,7 @@ export const projectMembershipServiceFactory = ({
|
|||||||
|
|
||||||
if (!ghostUser) {
|
if (!ghostUser) {
|
||||||
throw new BadRequestError({
|
throw new BadRequestError({
|
||||||
message: "Failed to find top-level user"
|
message: "Failed to find sudo user"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +256,7 @@ export const projectMembershipServiceFactory = ({
|
|||||||
|
|
||||||
if (!ghostUserLatestKey) {
|
if (!ghostUserLatestKey) {
|
||||||
throw new BadRequestError({
|
throw new BadRequestError({
|
||||||
message: "Failed to find top-level latest key"
|
message: "Failed to find sudo user latest key"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,6 +410,19 @@ export const projectMembershipServiceFactory = ({
|
|||||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId, actorOrgId);
|
||||||
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Member);
|
ForbiddenError.from(permission).throwUnlessCan(ProjectPermissionActions.Delete, ProjectPermissionSub.Member);
|
||||||
|
|
||||||
|
const project = await projectDAL.findById(projectId);
|
||||||
|
|
||||||
|
if (!project) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Project not found",
|
||||||
|
name: "Delete project membership"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (project.version === ProjectVersion.V1) {
|
||||||
|
throw new BadRequestError({ message: "Please upgrade your project on your dashboard" });
|
||||||
|
}
|
||||||
|
|
||||||
const projectMembers = await projectMembershipDAL.findMembershipsByEmail(projectId, emails);
|
const projectMembers = await projectMembershipDAL.findMembershipsByEmail(projectId, emails);
|
||||||
|
|
||||||
if (projectMembers.length !== emails.length) {
|
if (projectMembers.length !== emails.length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user