fix: Hide SAML/OIDC login button if no sso connection exists (Self hosted instance) (#10903)

Co-authored-by: zomars <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-10-09 16:30:30 +01:00
1 parent d8f6400add
commit b5cf4e50a9
4 files changed
+56 -6

No files matched your search

@@ -49,4 +49,11 @@ export const publicViewerRouter = router({
const handler = await importHandler(namespaced("event"), () => import("./event.handler"));
return handler(opts);
}),
ssoConnections: publicProcedure.query(async () => {
const handler = await importHandler(
namespaced("ssoConnections"),
() => import("./ssoConnections.handler")
);
return handler();
}),
});
@@ -0,0 +1,31 @@
import jackson from "@calcom/features/ee/sso/lib/jackson";
import { samlProductID, samlTenantID } from "@calcom/features/ee/sso/lib/saml";
import { HOSTED_CAL_FEATURES } from "@calcom/lib/constants";
import { TRPCError } from "@trpc/server";
export const handler = async () => {
try {
if (HOSTED_CAL_FEATURES) {
return {
connectionExists: null,
};
}
const { connectionController } = await jackson();
const connections = await connectionController.getConnections({
tenant: samlTenantID,
product: samlProductID,
});
return {
connectionExists: connections.length > 0,
};
} catch (err) {
console.error("Error getting SSO connections", err);
throw new TRPCError({ code: "BAD_REQUEST", message: "Fetching SSO connections failed." });
}
};
export default handler;