mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 09:26:47 +00:00
Feat: Default SAML/LDAP organization slug
This commit is contained in:
@@ -1,7 +1,30 @@
|
|||||||
import { TDbClient } from "@app/db";
|
import { TDbClient } from "@app/db";
|
||||||
import { TableName } from "@app/db/schemas";
|
import { TableName, TSuperAdmin } from "@app/db/schemas";
|
||||||
import { ormify } from "@app/lib/knex";
|
import { ormify } from "@app/lib/knex";
|
||||||
|
|
||||||
export type TSuperAdminDALFactory = ReturnType<typeof superAdminDALFactory>;
|
export type TSuperAdminDALFactory = ReturnType<typeof superAdminDALFactory>;
|
||||||
|
|
||||||
export const superAdminDALFactory = (db: TDbClient) => ormify(db, TableName.SuperAdmin, {});
|
export const superAdminDALFactory = (db: TDbClient) => {
|
||||||
|
const orm = ormify(db, TableName.SuperAdmin);
|
||||||
|
|
||||||
|
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`)
|
||||||
|
.select(
|
||||||
|
db.ref("*").withSchema(TableName.SuperAdmin) as unknown as keyof TSuperAdmin,
|
||||||
|
db.ref("slug").withSchema(TableName.Organization).as("defaultOrgSlug")
|
||||||
|
)
|
||||||
|
.first();
|
||||||
|
|
||||||
|
return {
|
||||||
|
defaultOrgSlug: config?.defaultOrgSlug || null,
|
||||||
|
...config
|
||||||
|
} as TSuperAdmin & { defaultOrgSlug: string | null };
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...orm,
|
||||||
|
findById
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user