Skip to content

Commit

Permalink
Merge pull request #967 from nickgros/PORTALS-3094
Browse files Browse the repository at this point in the history
PORTALS-3094 - do not show error when signing in with IdP + 2FA
  • Loading branch information
nickgros authored May 30, 2024
2 parents 334e196 + fa23ca0 commit 3dec388
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apps/synapse-oauth-signin/src/OAuth2Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -172,7 +180,7 @@ export function OAuth2Form() {
authRequest.claims = JSON.parse(claimsString)
}
return authRequest
}, [onError, queryParams])
}, [isHandlingSignInFromExternalIdP, onError, queryParams])

const { data: hasUserAuthorizedOAuthClient } =
SynapseQueries.useGetHasUserAuthorizedOAuthClient(
Expand Down
2 changes: 2 additions & 0 deletions apps/synapse-oauth-signin/src/test/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down

0 comments on commit 3dec388

Please sign in to comment.