Fix: SAML CLI login

This commit is contained in:
Daniel Hougaard
2024-03-18 10:37:49 +01:00
parent cd192ee228
commit 88e2eff7eb
@@ -54,20 +54,25 @@ export default function LoginPage() {
const handleSelectOrganization = useCallback( const handleSelectOrganization = useCallback(
async (organization: Organization) => { async (organization: Organization) => {
const callbackPort = queryParams.get("callback_port");
if (organization.authEnforced) { if (organization.authEnforced) {
// org has an org-level auth method enabled (e.g. SAML) // org has an org-level auth method enabled (e.g. SAML)
// -> logout + redirect to SAML SSO // -> logout + redirect to SAML SSO
let samlUrl = `/api/v1/sso/redirect/saml2/organizations/${organization.slug}`;
if (callbackPort) {
samlUrl += `?callback_port=${callbackPort}`;
}
await logout.mutateAsync(); await logout.mutateAsync();
window.open(`/api/v1/sso/redirect/saml2/organizations/${organization.slug}`); window.open(samlUrl);
window.close(); window.close();
return; return;
} }
const { token } = await selectOrg.mutateAsync({ organizationId: organization.id }); const { token } = await selectOrg.mutateAsync({ organizationId: organization.id });
const callbackPort = queryParams.get("callback_port");
if (callbackPort) { if (callbackPort) {
const privateKey = localStorage.getItem("PRIVATE_KEY"); const privateKey = localStorage.getItem("PRIVATE_KEY");