diff --git a/apps/synapse-oauth-signin/src/OAuth2Form.tsx b/apps/synapse-oauth-signin/src/OAuth2Form.tsx index 098a83e2f2..e6e0c28f6e 100644 --- a/apps/synapse-oauth-signin/src/OAuth2Form.tsx +++ b/apps/synapse-oauth-signin/src/OAuth2Form.tsx @@ -63,6 +63,9 @@ export function OAuth2Form() { // The target URL may take a while to respond, so we show a loader to inform the user that the delay is not our fault const [showPendingRedirectUI, setShowPendingRedirectUI] = useState(false) + // If the URL contains a provider, then we are in the middle of authenticating after coming from an external IdP (e.g. Google, ORCID) + const isHandlingSignInFromExternalIdP = Boolean(queryParams.get('provider')) + const onError = useCallback( (error: Error | OAuthClientError | SynapseClientError) => { if (error instanceof SynapseClientError && error.status === 401) { @@ -129,6 +132,11 @@ export function OAuth2Form() { const oidcAuthorizationRequestFromSearchParams: | OIDCAuthorizationRequest | undefined = useMemo(() => { + if (isHandlingSignInFromExternalIdP) { + // The user is in the middle of signing in with an external IdP, so the URL will not yet have the required parameters + // Don't make the OIDC authorization request, and don't show an error. + return undefined + } const missingParams: string[] = [] const clientId = queryParams.get('client_id') @@ -172,7 +180,7 @@ export function OAuth2Form() { authRequest.claims = JSON.parse(claimsString) } return authRequest - }, [onError, queryParams]) + }, [isHandlingSignInFromExternalIdP, onError, queryParams]) const { data: hasUserAuthorizedOAuthClient } = SynapseQueries.useGetHasUserAuthorizedOAuthClient( diff --git a/apps/synapse-oauth-signin/src/test/App.test.tsx b/apps/synapse-oauth-signin/src/test/App.test.tsx index 9235e000ea..aa21f7b7b7 100644 --- a/apps/synapse-oauth-signin/src/test/App.test.tsx +++ b/apps/synapse-oauth-signin/src/test/App.test.tsx @@ -418,6 +418,8 @@ describe('App integration tests', () => { ) }) + // No errors should be shown (such as in PORTALS-3094) + expect(screen.queryByRole('alert')).toBe(null) // Verify the TOTP prompt is on-screen and type in '123456' await screen.findByText( 'Enter the 6-digit, time-based verification code provided by your authenticator app.',