mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 19:44:52 +00:00
Updated "defaultOrgId" and "defaultOrgSlug" to "defaultAuthOrgId" and "defaultAuthOrgSlug"
This commit is contained in:
@@ -10,17 +10,17 @@ export const superAdminDALFactory = (db: TDbClient) => {
|
||||
const findById = async (id: string) => {
|
||||
const config = await db(TableName.SuperAdmin)
|
||||
.where(`${TableName.SuperAdmin}.id`, id)
|
||||
.leftJoin(TableName.Organization, `${TableName.SuperAdmin}.defaultOrgId`, `${TableName.Organization}.id`)
|
||||
.leftJoin(TableName.Organization, `${TableName.SuperAdmin}.defaultAuthOrgId`, `${TableName.Organization}.id`)
|
||||
.select(
|
||||
db.ref("*").withSchema(TableName.SuperAdmin) as unknown as keyof TSuperAdmin,
|
||||
db.ref("slug").withSchema(TableName.Organization).as("defaultOrgSlug")
|
||||
db.ref("slug").withSchema(TableName.Organization).as("defaultAuthOrgSlug")
|
||||
)
|
||||
.first();
|
||||
|
||||
return {
|
||||
defaultOrgSlug: config?.defaultOrgSlug || null,
|
||||
defaultAuthOrgSlug: config?.defaultAuthOrgSlug || null,
|
||||
...config
|
||||
} as TSuperAdmin & { defaultOrgSlug: string | null };
|
||||
} as TSuperAdmin & { defaultAuthOrgSlug: string | null };
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -28,7 +28,7 @@ type TSuperAdminServiceFactoryDep = {
|
||||
export type TSuperAdminServiceFactory = ReturnType<typeof superAdminServiceFactory>;
|
||||
|
||||
// eslint-disable-next-line
|
||||
export let getServerCfg: () => Promise<TSuperAdmin & { defaultOrgSlug: string | null }>;
|
||||
export let getServerCfg: () => Promise<TSuperAdmin & { defaultAuthOrgSlug: string | null }>;
|
||||
|
||||
const ADMIN_CONFIG_KEY = "infisical-admin-cfg";
|
||||
const ADMIN_CONFIG_KEY_EXP = 60; // 60s
|
||||
@@ -57,7 +57,7 @@ export const superAdminServiceFactory = ({
|
||||
return serverCfg;
|
||||
}
|
||||
|
||||
const keyStoreServerCfg = JSON.parse(config) as TSuperAdmin & { defaultOrgSlug: string | null };
|
||||
const keyStoreServerCfg = JSON.parse(config) as TSuperAdmin & { defaultAuthOrgSlug: string | null };
|
||||
return {
|
||||
...keyStoreServerCfg,
|
||||
// this is to allow admin router to work
|
||||
@@ -78,9 +78,9 @@ export const superAdminServiceFactory = ({
|
||||
|
||||
const updateServerCfg = async (data: TUpdateServerCfgDTO) => {
|
||||
let organization: TOrganizations | undefined;
|
||||
if (data.defaultOrgSlug) {
|
||||
if (data.defaultAuthOrgSlug) {
|
||||
organization = await orgDAL.findOne({
|
||||
slug: data.defaultOrgSlug
|
||||
slug: data.defaultAuthOrgSlug
|
||||
});
|
||||
|
||||
if (!organization) {
|
||||
@@ -92,13 +92,13 @@ export const superAdminServiceFactory = ({
|
||||
}
|
||||
|
||||
const updatedServerCfg = await serverCfgDAL.updateById(ADMIN_CONFIG_DB_UUID, {
|
||||
...omit(data, ["defaultOrgSlug"]),
|
||||
defaultOrgId: organization?.id || null
|
||||
...omit(data, ["defaultAuthOrgSlug"]),
|
||||
defaultAuthOrgId: organization?.id || null
|
||||
});
|
||||
|
||||
const result = {
|
||||
...updatedServerCfg,
|
||||
defaultOrgSlug: organization?.slug || null
|
||||
defaultAuthOrgSlug: organization?.slug || null
|
||||
};
|
||||
|
||||
await keyStore.setItemWithExpiry(ADMIN_CONFIG_KEY, ADMIN_CONFIG_KEY_EXP, JSON.stringify(result));
|
||||
|
||||
@@ -18,6 +18,6 @@ export type TAdminSignUpDTO = {
|
||||
userAgent: string;
|
||||
};
|
||||
|
||||
export type TUpdateServerCfgDTO = Omit<TSuperAdminUpdate, "defaultOrgId"> & {
|
||||
defaultOrgSlug?: string | null;
|
||||
export type TUpdateServerCfgDTO = Omit<TSuperAdminUpdate, "defaultAuthOrgId"> & {
|
||||
defaultAuthOrgSlug?: string | null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user