mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-02 22:25:44 +00:00
add tx to find ghost user
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { Knex } from "knex";
|
||||||
|
|
||||||
import { TDbClient } from "@app/db";
|
import { TDbClient } from "@app/db";
|
||||||
import { TableName, TUserEncryptionKeys } from "@app/db/schemas";
|
import { TableName, TUserEncryptionKeys } from "@app/db/schemas";
|
||||||
import { DatabaseError } from "@app/lib/errors";
|
import { DatabaseError } from "@app/lib/errors";
|
||||||
@@ -104,9 +106,9 @@ export const projectMembershipDALFactory = (db: TDbClient) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const findProjectGhostUser = async (projectId: string) => {
|
const findProjectGhostUser = async (projectId: string, tx?: Knex) => {
|
||||||
try {
|
try {
|
||||||
const ghostUser = await db(TableName.ProjectMembership)
|
const ghostUser = await (tx || db)(TableName.ProjectMembership)
|
||||||
.where({ projectId })
|
.where({ projectId })
|
||||||
.join(TableName.Users, `${TableName.ProjectMembership}.userId`, `${TableName.Users}.id`)
|
.join(TableName.Users, `${TableName.ProjectMembership}.userId`, `${TableName.Users}.id`)
|
||||||
.select(selectAllTableCols(TableName.Users))
|
.select(selectAllTableCols(TableName.Users))
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ export const projectServiceFactory = ({
|
|||||||
|
|
||||||
const deletedProject = await projectDAL.transaction(async (tx) => {
|
const deletedProject = await projectDAL.transaction(async (tx) => {
|
||||||
const delProject = await projectDAL.deleteById(project.id, tx);
|
const delProject = await projectDAL.deleteById(project.id, tx);
|
||||||
const projectGhostUser = await projectMembershipDAL.findProjectGhostUser(project.id).catch(() => null);
|
const projectGhostUser = await projectMembershipDAL.findProjectGhostUser(project.id, tx).catch(() => null);
|
||||||
|
|
||||||
// Delete the org membership for the ghost user if it's found.
|
// Delete the org membership for the ghost user if it's found.
|
||||||
if (projectGhostUser) {
|
if (projectGhostUser) {
|
||||||
|
|||||||
Reference in New Issue
Block a user