fix: remove undefined return type from get saml endpoint

This commit is contained in:
Daniel Hougaard
2025-07-04 05:07:54 +04:00
parent cda8579ca4
commit 65b1354ef1
4 changed files with 34 additions and 31 deletions
+11 -13
View File
@@ -277,19 +277,17 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
organizationId: z.string().trim().describe(SamlSso.GET_CONFIG.organizationId) organizationId: z.string().trim().describe(SamlSso.GET_CONFIG.organizationId)
}), }),
response: { response: {
200: z 200: z.object({
.object({ id: z.string(),
id: z.string(), organization: z.string(),
organization: z.string(), orgId: z.string(),
orgId: z.string(), authProvider: z.string(),
authProvider: z.string(), isActive: z.boolean(),
isActive: z.boolean(), entryPoint: z.string(),
entryPoint: z.string(), issuer: z.string(),
issuer: z.string(), cert: z.string(),
cert: z.string(), lastUsed: z.date().nullable().optional()
lastUsed: z.date().nullable().optional() })
})
.optional()
} }
}, },
handler: async (req) => { handler: async (req) => {
@@ -148,10 +148,18 @@ export const samlConfigServiceFactory = ({
let samlConfig: TSamlConfigs | undefined; let samlConfig: TSamlConfigs | undefined;
if (dto.type === "org") { if (dto.type === "org") {
samlConfig = await samlConfigDAL.findOne({ orgId: dto.orgId }); samlConfig = await samlConfigDAL.findOne({ orgId: dto.orgId });
if (!samlConfig) return; if (!samlConfig) {
throw new NotFoundError({
message: `Organization with ID '${dto.orgId}' not found`
});
}
} else if (dto.type === "orgSlug") { } else if (dto.type === "orgSlug") {
const org = await orgDAL.findOne({ slug: dto.orgSlug }); const org = await orgDAL.findOne({ slug: dto.orgSlug });
if (!org) return; if (!org) {
throw new NotFoundError({
message: `Organization with slug '${dto.orgSlug}' not found`
});
}
samlConfig = await samlConfigDAL.findOne({ orgId: org.id }); samlConfig = await samlConfigDAL.findOne({ orgId: org.id });
} else if (dto.type === "ssoId") { } else if (dto.type === "ssoId") {
// TODO: // TODO:
@@ -61,20 +61,17 @@ export type TSamlLoginDTO = {
export type TSamlConfigServiceFactory = { export type TSamlConfigServiceFactory = {
createSamlCfg: (arg: TCreateSamlCfgDTO) => Promise<TSamlConfigs>; createSamlCfg: (arg: TCreateSamlCfgDTO) => Promise<TSamlConfigs>;
updateSamlCfg: (arg: TUpdateSamlCfgDTO) => Promise<TSamlConfigs>; updateSamlCfg: (arg: TUpdateSamlCfgDTO) => Promise<TSamlConfigs>;
getSaml: (arg: TGetSamlCfgDTO) => Promise< getSaml: (arg: TGetSamlCfgDTO) => Promise<{
| { id: string;
id: string; organization: string;
organization: string; orgId: string;
orgId: string; authProvider: string;
authProvider: string; isActive: boolean;
isActive: boolean; entryPoint: string;
entryPoint: string; issuer: string;
issuer: string; cert: string;
cert: string; lastUsed: Date | null | undefined;
lastUsed: Date | null | undefined; }>;
}
| undefined
>;
samlLogin: (arg: TSamlLoginDTO) => Promise<{ samlLogin: (arg: TSamlLoginDTO) => Promise<{
isUserCompleted: boolean; isUserCompleted: boolean;
providerAuthToken: string; providerAuthToken: string;
+2 -2
View File
@@ -2706,7 +2706,7 @@ export const SamlSso = {
}, },
UPDATE_CONFIG: { UPDATE_CONFIG: {
organizationId: "The ID of the organization to update the SAML config for.", organizationId: "The ID of the organization to update the SAML config for.",
authProvider: "The authentication provider to use for SAML authentication.", authProvider: "Authentication provider to use for SAML authentication.",
isActive: "Whether to enable or disable this SAML configuration.", isActive: "Whether to enable or disable this SAML configuration.",
entryPoint: entryPoint:
"The entry point for the SAML authentication. This is the URL that the user will be redirected to after they have authenticated with the SAML provider.", "The entry point for the SAML authentication. This is the URL that the user will be redirected to after they have authenticated with the SAML provider.",
@@ -2715,7 +2715,7 @@ export const SamlSso = {
}, },
CREATE_CONFIG: { CREATE_CONFIG: {
organizationId: "The ID of the organization to create the SAML config for.", organizationId: "The ID of the organization to create the SAML config for.",
authProvider: "The authentication provider to use for SAML authentication.", authProvider: "Authentication provider to use for SAML authentication.",
isActive: "Whether to enable or disable this SAML configuration.", isActive: "Whether to enable or disable this SAML configuration.",
entryPoint: entryPoint:
"The entry point for the SAML authentication. This is the URL that the user will be redirected to after they have authenticated with the SAML provider.", "The entry point for the SAML authentication. This is the URL that the user will be redirected to after they have authenticated with the SAML provider.",