Requested changes

This commit is contained in:
Daniel Hougaard
2024-02-22 05:00:26 +01:00
parent 419916ee0c
commit a6e263eded
21 changed files with 53 additions and 41 deletions
@@ -24,17 +24,17 @@ export const projectMembershipDALFactory = (db: TDbClient) => {
db.ref("projectId").withSchema(TableName.ProjectMembership),
db.ref("role").withSchema(TableName.ProjectMembership),
db.ref("roleId").withSchema(TableName.ProjectMembership),
db.ref("ghost").withSchema(TableName.Users),
db.ref("isGhost").withSchema(TableName.Users),
db.ref("email").withSchema(TableName.Users),
db.ref("publicKey").withSchema(TableName.UserEncryptionKey),
db.ref("firstName").withSchema(TableName.Users),
db.ref("lastName").withSchema(TableName.Users),
db.ref("id").withSchema(TableName.Users).as("userId")
)
.where({ ghost: false });
return members.map(({ email, firstName, lastName, publicKey, ghost, ...data }) => ({
.where({ isGhost: false });
return members.map(({ email, firstName, lastName, publicKey, isGhost, ...data }) => ({
...data,
user: { email, firstName, lastName, id: data.userId, publicKey, ghost }
user: { email, firstName, lastName, id: data.userId, publicKey, isGhost }
}));
} catch (error) {
throw new DatabaseError({ error, name: "Find all project members" });
@@ -47,7 +47,7 @@ export const projectMembershipDALFactory = (db: TDbClient) => {
.where({ projectId })
.join(TableName.Users, `${TableName.ProjectMembership}.userId`, `${TableName.Users}.id`)
.select(selectAllTableCols(TableName.Users))
.where({ ghost: true })
.where({ isGhost: true })
.first();
return ghostUser;
@@ -72,7 +72,7 @@ export const projectMembershipDALFactory = (db: TDbClient) => {
db.ref("email").withSchema(TableName.Users)
)
.whereIn("email", emails)
.where({ ghost: false });
.where({ isGhost: false });
return members.map(({ userId, email, ...data }) => ({
...data,
user: { id: userId, email }
@@ -16,11 +16,11 @@ import { getConfig } from "@app/lib/config/env";
import { infisicalSymmetricDecrypt } from "@app/lib/crypto/encryption";
import { BadRequestError } from "@app/lib/errors";
import { groupBy } from "@app/lib/fn";
import { createWsMembers } from "@app/lib/project";
import { ActorType } from "../auth/auth-type";
import { TOrgDALFactory } from "../org/org-dal";
import { TProjectDALFactory } from "../project/project-dal";
import { createWsMembers } from "../project/project-fns";
import { TProjectBotDALFactory } from "../project-bot/project-bot-dal";
import { TProjectKeyDALFactory } from "../project-key/project-key-dal";
import { TProjectRoleDALFactory } from "../project-role/project-role-dal";
@@ -320,7 +320,7 @@ export const projectMembershipServiceFactory = ({
const membershipUser = await userDAL.findUserByProjectMembershipId(membershipId);
if (membershipUser?.ghost) {
if (membershipUser?.isGhost) {
throw new BadRequestError({
message: "Unauthorized member update",
name: "Update project membership"
@@ -365,7 +365,7 @@ export const projectMembershipServiceFactory = ({
const member = await userDAL.findUserByProjectMembershipId(membershipId);
if (member?.ghost) {
if (member?.isGhost) {
throw new BadRequestError({
message: "Unauthorized member delete",
name: "Delete project membership"