Fix: SAML CLI login

This commit is contained in:
Daniel Hougaard
2024-03-18 10:37:49 +01:00
parent cd192ee228
commit 88e2eff7eb

View File

@ -54,20 +54,25 @@ export default function LoginPage() {
const handleSelectOrganization = useCallback(
async (organization: Organization) => {
const callbackPort = queryParams.get("callback_port");
if (organization.authEnforced) {
// org has an org-level auth method enabled (e.g. SAML)
// -> logout + redirect to SAML SSO
let samlUrl = `/api/v1/sso/redirect/saml2/organizations/${organization.slug}`;
if (callbackPort) {
samlUrl += `?callback_port=${callbackPort}`;
}
await logout.mutateAsync();
window.open(`/api/v1/sso/redirect/saml2/organizations/${organization.slug}`);
window.open(samlUrl);
window.close();
return;
}
const { token } = await selectOrg.mutateAsync({ organizationId: organization.id });
const callbackPort = queryParams.get("callback_port");
if (callbackPort) {
const privateKey = localStorage.getItem("PRIVATE_KEY");