Skip to content

Commit

Permalink
Improve the logic for SSO auth buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
zlwaterfield committed Oct 29, 2024
1 parent edb0408 commit b1a6a13
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
12 changes: 9 additions & 3 deletions frontend/src/scenes/authentication/InviteSignup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function UnauthenticatedAcceptInvite({ invite }: { invite: PrevalidatedInvite })
const { precheck } = useActions(loginLogic)
const { precheckResponse, precheckResponseLoading, login } = useValues(loginLogic)

const areExtraFieldsHidden = precheckResponse.status === 'pending' || precheckResponse.sso_enforcement
const areExtraFieldsHidden = precheckResponse.sso_enforcement

useEffect(() => {
precheck({ email: invite.target_email })
Expand Down Expand Up @@ -270,7 +270,8 @@ function UnauthenticatedAcceptInvite({ invite }: { invite: PrevalidatedInvite })
</>
)}

{precheckResponse.status === 'pending' || !precheckResponse.sso_enforcement ? (
{/* Show regular login button if SSO is not enforced */}
{!precheckResponse.sso_enforcement && (
<LemonButton
type="primary"
status="alt"
Expand All @@ -283,14 +284,19 @@ function UnauthenticatedAcceptInvite({ invite }: { invite: PrevalidatedInvite })
>
Continue
</LemonButton>
) : (
)}

{/* Show enforced SSO button if required */}
{precheckResponse.sso_enforcement && (
<SSOEnforcedLoginButton
provider={precheckResponse.sso_enforcement}
email={login.email}
actionText="Continue"
extraQueryParams={invite ? { invite_id: invite.id } : undefined}
/>
)}

{/* Show optional SAML SSO button if available */}
{precheckResponse.saml_available && !precheckResponse.sso_enforcement && (
<SSOEnforcedLoginButton
provider="saml"
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/scenes/authentication/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ export function Login(): JSX.Element {
/>
</LemonField>
</div>
{precheckResponse.status === 'pending' || !precheckResponse.sso_enforcement ? (

{/* Show regular login button if SSO is not enforced */}
{!precheckResponse.sso_enforcement && (
<LemonButton
type="primary"
status="alt"
Expand All @@ -153,9 +155,14 @@ export function Login(): JSX.Element {
>
Log in
</LemonButton>
) : (
)}

{/* Show enforced SSO button if required */}
{precheckResponse.sso_enforcement && (
<SSOEnforcedLoginButton provider={precheckResponse.sso_enforcement} email={login.email} />
)}

{/* Show optional SAML SSO button if available */}
{precheckResponse.saml_available && !precheckResponse.sso_enforcement && (
<SSOEnforcedLoginButton provider="saml" email={login.email} />
)}
Expand Down

0 comments on commit b1a6a13

Please sign in to comment.