-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into IOCOM-1761-ui-alert-o-bottom-sheet-per-il-…
…non-mostrare-piu-e-logica-di-visualizzazione
- Loading branch information
Showing
24 changed files
with
374 additions
and
1,251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
ts/features/fims/singleSignOn/saga/handleFIMSAcceptedConsents.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { ActionType } from "typesafe-actions"; | ||
import { call, put, select } from "typed-redux-saga/macro"; | ||
import { isCancelledFailure } from "@pagopa/io-react-native-http-client"; | ||
import { | ||
fimsAcceptConsentsAction, | ||
fimsAcceptConsentsFailureAction, | ||
fimsSignAndRetrieveInAppBrowserUrlAction | ||
} from "../store/actions"; | ||
import { oidcProviderDomainSelector } from "../../../../store/reducers/backendStatus/remoteConfig"; | ||
import { | ||
absoluteRedirectUrl, | ||
computeAndTrackAuthenticationError, | ||
deallocateFimsAndRenewFastLoginSession, | ||
followProviderRedirects, | ||
formatHttpClientResponseForMixPanel, | ||
isFastLoginFailure | ||
} from "./sagaUtils"; | ||
|
||
export function* handleFimsAcceptedConsents( | ||
action: ActionType<typeof fimsAcceptConsentsAction> | ||
) { | ||
const oidcProviderDomain = yield* select(oidcProviderDomainSelector); | ||
if (!oidcProviderDomain) { | ||
const debugMessage = `missing FIMS, domain is ${oidcProviderDomain}`; | ||
yield* call(computeAndTrackAuthenticationError, debugMessage); | ||
yield* put( | ||
fimsAcceptConsentsFailureAction({ | ||
errorTag: "GENERIC", | ||
debugMessage | ||
}) | ||
); | ||
return; | ||
} | ||
const maybeAcceptUrl = action.payload.acceptUrl; | ||
|
||
const acceptUrl = absoluteRedirectUrl( | ||
maybeAcceptUrl ?? "", | ||
oidcProviderDomain | ||
); | ||
if (!acceptUrl) { | ||
const debugMessage = `unable to accept grants, could not build url. obtained URL: ${maybeAcceptUrl}`; | ||
yield* call(computeAndTrackAuthenticationError, debugMessage); | ||
yield* put( | ||
fimsAcceptConsentsFailureAction({ | ||
errorTag: "GENERIC", | ||
debugMessage | ||
}) | ||
); | ||
return; | ||
} | ||
|
||
const rpRedirectResponse = yield* call( | ||
followProviderRedirects, | ||
{ url: acceptUrl, verb: "post" }, | ||
oidcProviderDomain | ||
); | ||
|
||
if (rpRedirectResponse.type === "failure") { | ||
if (isCancelledFailure(rpRedirectResponse)) { | ||
return; | ||
} | ||
if (isFastLoginFailure(rpRedirectResponse)) { | ||
yield* call(deallocateFimsAndRenewFastLoginSession); | ||
return; | ||
} | ||
const debugMessage = `could not get RelyingParty redirect URL, ${formatHttpClientResponseForMixPanel( | ||
rpRedirectResponse | ||
)}`; | ||
yield* call(computeAndTrackAuthenticationError, debugMessage); | ||
yield* put( | ||
fimsAcceptConsentsFailureAction({ | ||
errorTag: "GENERIC", | ||
debugMessage | ||
}) | ||
); | ||
return; | ||
} | ||
|
||
yield* put( | ||
fimsSignAndRetrieveInAppBrowserUrlAction.request(rpRedirectResponse) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.