Skip to content

Commit

Permalink
fix: [IOCOM-1994,IOCOM-1995] Fix for back behaviours on FIMS Auth (#6481
Browse files Browse the repository at this point in the history
)

## Short description
This PR fixes some anomalies on the back behaviour for the FIMS' Auth
flow

## List of changes proposed in this pull request
- When going back from an error screen, proper deallocation of FIMS
resources was not triggered (using navigation.back instead of back saga)
- On Android, physical back button event is not handled by the
assistance modal and is propagated to the underlying screen. If this
happens on the FIMS' consents screen, the flow is interrupted. Since
this anomaly affects the entire app, the back capturing has been
disabled and the user has to rely on the UI back buttons

## How to test
Using the io-dev-api-server, check that:
- the FIMS flow can be successfully retried after an error
- the Android back button does nothing on the FIMS' Auth flow

Co-authored-by: Martino Cesari Tomba <[email protected]>
  • Loading branch information
Vangaorth and forrest57 authored Dec 4, 2024
1 parent 2fbaa6c commit e05a6a3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
19 changes: 13 additions & 6 deletions ts/features/fims/singleSignOn/components/FimsFullScreenErrors.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
import { useNavigation } from "@react-navigation/native";
import * as React from "react";
import {
OperationResultScreenContent,
OperationResultScreenContentProps
} from "../../../../components/screens/OperationResultScreenContent";
import I18n from "../../../../i18n";
import { useIOSelector } from "../../../../store/hooks";
import { useIODispatch, useIOSelector } from "../../../../store/hooks";
import {
fimsAuthenticationErrorTagSelector,
fimsDebugDataSelector
} from "../store/selectors";
import { useDebugInfo } from "../../../../hooks/useDebugInfo";
import { fimsCancelOrAbortAction } from "../store/actions";

export const FimsSSOFullScreenError = () => {
const navigation = useNavigation();
const dispatch = useIODispatch();
const errorTag = useIOSelector(fimsAuthenticationErrorTagSelector);
const debugData = useIOSelector(fimsDebugDataSelector);

const debugInfo = React.useMemo(
() => ({
fimsFailure: `${errorTag}: ${debugData}`
}),
[debugData, errorTag]
);
useDebugInfo(debugInfo);

const handleClose = React.useCallback(
() => dispatch(fimsCancelOrAbortAction()),
[dispatch]
);

const getErrorComponentProps = (): OperationResultScreenContentProps => {
switch (errorTag) {
case "AUTHENTICATION":
Expand All @@ -35,7 +42,7 @@ export const FimsSSOFullScreenError = () => {
pictogram: "umbrellaNew",
action: {
label: I18n.t("global.buttons.close"),
onPress: navigation.goBack
onPress: handleClose
}
};
case "MISSING_INAPP_BROWSER":
Expand All @@ -50,7 +57,7 @@ export const FimsSSOFullScreenError = () => {
pictogram: "updateOS",
action: {
label: I18n.t("global.buttons.close"),
onPress: navigation.goBack
onPress: handleClose
}
};
default:
Expand All @@ -61,7 +68,7 @@ export const FimsSSOFullScreenError = () => {
pictogram: "umbrellaNew",
action: {
label: I18n.t("global.buttons.close"),
onPress: navigation.goBack
onPress: handleClose
}
};
}
Expand Down
12 changes: 7 additions & 5 deletions ts/features/fims/singleSignOn/screens/FimsFlowHandlerScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Body, IOStyles } from "@pagopa/io-app-design-system";
import * as pot from "@pagopa/ts-commons/lib/pot";
import { pipe } from "fp-ts/lib/function";
import { constTrue, pipe } from "fp-ts/lib/function";
import * as O from "fp-ts/Option";
import * as React from "react";
import { View } from "react-native";
Expand Down Expand Up @@ -64,10 +64,12 @@ export const FimsFlowHandlerScreen = (
goBack: handleCancelOrAbort
});

useHardwareBackButton(() => {
handleCancelOrAbort();
return true;
});
// Force users on Android to use UI buttons to go back, since
// there are cases where a modal may be displayed on top of
// the screen (like the assistance one) and the hardware back
// button event is not stopped by such screen but is instead
// propagated to this UI, causing a back loop
useHardwareBackButton(constTrue);

React.useEffect(() => {
if (ctaUrl && !requiresAppUpdate) {
Expand Down

0 comments on commit e05a6a3

Please sign in to comment.