mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 12:28:54 +00:00
Akhil requested changes
This commit is contained in:
@@ -122,7 +122,7 @@ export const orgDALFactory = (db: TDbClient) => {
|
|||||||
|
|
||||||
const findOrgGhostUser = async (orgId: string) => {
|
const findOrgGhostUser = async (orgId: string) => {
|
||||||
try {
|
try {
|
||||||
const [member] = await db(TableName.OrgMembership)
|
const member = await db(TableName.OrgMembership)
|
||||||
.where({ orgId })
|
.where({ orgId })
|
||||||
.join(TableName.Users, `${TableName.OrgMembership}.userId`, `${TableName.Users}.id`)
|
.join(TableName.Users, `${TableName.OrgMembership}.userId`, `${TableName.Users}.id`)
|
||||||
.leftJoin(TableName.UserEncryptionKey, `${TableName.UserEncryptionKey}.userId`, `${TableName.Users}.id`)
|
.leftJoin(TableName.UserEncryptionKey, `${TableName.UserEncryptionKey}.userId`, `${TableName.Users}.id`)
|
||||||
@@ -136,7 +136,8 @@ export const orgDALFactory = (db: TDbClient) => {
|
|||||||
db.ref("id").withSchema(TableName.Users).as("userId"),
|
db.ref("id").withSchema(TableName.Users).as("userId"),
|
||||||
db.ref("publicKey").withSchema(TableName.UserEncryptionKey)
|
db.ref("publicKey").withSchema(TableName.UserEncryptionKey)
|
||||||
)
|
)
|
||||||
.where({ isGhost: true });
|
.where({ isGhost: true })
|
||||||
|
.first();
|
||||||
return member;
|
return member;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return null;
|
return null;
|
||||||
@@ -145,13 +146,14 @@ export const orgDALFactory = (db: TDbClient) => {
|
|||||||
|
|
||||||
const ghostUserExists = async (orgId: string) => {
|
const ghostUserExists = async (orgId: string) => {
|
||||||
try {
|
try {
|
||||||
const [member] = await db(TableName.OrgMembership)
|
const member = await db(TableName.OrgMembership)
|
||||||
.where({ orgId })
|
.where({ orgId })
|
||||||
.join(TableName.Users, `${TableName.OrgMembership}.userId`, `${TableName.Users}.id`)
|
.join(TableName.Users, `${TableName.OrgMembership}.userId`, `${TableName.Users}.id`)
|
||||||
.leftJoin(TableName.UserEncryptionKey, `${TableName.UserEncryptionKey}.userId`, `${TableName.Users}.id`)
|
.leftJoin(TableName.UserEncryptionKey, `${TableName.UserEncryptionKey}.userId`, `${TableName.Users}.id`)
|
||||||
.select(db.ref("id").withSchema(TableName.Users).as("userId"))
|
.select(db.ref("id").withSchema(TableName.Users).as("userId"))
|
||||||
.where({ isGhost: true });
|
.where({ isGhost: true })
|
||||||
return !!member;
|
.first();
|
||||||
|
return Boolean(member);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ export const orgServiceFactory = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addGhostUser = async (orgId: string, tx?: Knex) => {
|
const addGhostUser = async (orgId: string, tx?: Knex) => {
|
||||||
const email = `ghost@${nanoid(16)}-${orgId}.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 = `ghost-${nanoid(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(
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// import { SecretKeyEncoding } from "@app/db/schemas";
|
|
||||||
import { TProjectBots } from "@app/db/schemas";
|
import { TProjectBots } from "@app/db/schemas";
|
||||||
import { TProjectPermission } from "@app/lib/types";
|
import { TProjectPermission } from "@app/lib/types";
|
||||||
|
|
||||||
@@ -21,10 +20,5 @@ export type TFindBotByProjectIdDTO = {
|
|||||||
} & TProjectPermission;
|
} & TProjectPermission;
|
||||||
|
|
||||||
export type TGetPrivateKeyDTO = {
|
export type TGetPrivateKeyDTO = {
|
||||||
// encoding: SecretKeyEncoding;
|
|
||||||
// nonce: string;
|
|
||||||
// tag: string;
|
|
||||||
// encryptedPrivateKey: string;
|
|
||||||
|
|
||||||
bot: TProjectBots;
|
bot: TProjectBots;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user