Skip to content

Commit

Permalink
fix: [#175949490] Request current PIN before letting the user change …
Browse files Browse the repository at this point in the history
…it (#2599)

* added current PIN request action

* added <<please restart app>> modal upon completion

* added comment about why we need the modal

* properly passing undefined to action

Co-authored-by: Matteo Boschi <[email protected]>
  • Loading branch information
DavideValdo and Undermaken authored Dec 18, 2020
1 parent 7e3d7a7 commit 7b01871
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
19 changes: 18 additions & 1 deletion ts/screens/onboarding/PinScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ import { maybeNotNullyString } from "../../utils/strings";
import { GlobalState } from "../../store/reducers/types";
import { isOnboardingCompletedSelector } from "../../store/reducers/navigationHistory";
import { instabugLog, TypeLogs } from "../../boot/configureInstabug";
import { AlertModal } from "../../components/ui/AlertModal";
import { withLightModalContext } from "../../components/helpers/withLightModalContext";
import { LightModalContextInterface } from "../../components/ui/LightModal";

type Props = NavigationScreenProps &
LightModalContextInterface &
ReturnType<typeof mapDispatchToProps> &
ReturnType<typeof mapStateToProps>;

Expand Down Expand Up @@ -374,6 +378,14 @@ class PinScreen extends React.PureComponent<Props, State> {
);
};

private showModal() {
this.props.showModal(
<AlertModal
message={I18n.t("profile.main.pagoPaEnvironment.alertMessage")}
/>
);
}

public render() {
const { pinState } = this.state;

Expand Down Expand Up @@ -413,6 +425,8 @@ class PinScreen extends React.PureComponent<Props, State> {
this.props.createPinSuccess(pin);
// user is updating his/her pin inside the app, go back
if (this.props.isOnboardingCompleted) {
// We need to ask the user to restart the app
this.showModal();
this.props.navigation.goBack();
}
},
Expand Down Expand Up @@ -447,4 +461,7 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
abortOnboarding: () => dispatch(abortOnboarding())
});

export default connect(mapStateToProps, mapDispatchToProps)(PinScreen);
export default connect(
mapStateToProps,
mapDispatchToProps
)(withLightModalContext(PinScreen));
24 changes: 20 additions & 4 deletions ts/screens/profile/ProfileMainScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ import { AlertModal } from "../../components/ui/AlertModal";
import { LightModalContextInterface } from "../../components/ui/LightModal";
import Markdown from "../../components/ui/Markdown";
import Switch from "../../components/ui/Switch";
import { isPlaygroundsEnabled } from "../../config";
import { isPlaygroundsEnabled, shufflePinPadOnPayment } from "../../config";
import I18n from "../../i18n";
import ROUTES from "../../navigation/routes";
import {
logoutRequest,
sessionExpired
} from "../../store/actions/authentication";
import { setDebugModeEnabled } from "../../store/actions/debug";
import { identificationRequest } from "../../store/actions/identification";
import {
preferencesExperimentalFeaturesSetEnabled,
preferencesPagoPaTestEnvironmentSetEnabled
Expand Down Expand Up @@ -365,11 +366,11 @@ class ProfileMainScreen extends React.PureComponent<Props, State> {
sectionHeader={I18n.t("profile.main.accountSectionHeader")}
/>

{/* Reset unlock code */}
{/* Ask for verification and reset unlock code */}
<ListItemComponent
title={I18n.t("identification.unlockCode.reset.button_short")}
subTitle={I18n.t("identification.unlockCode.reset.subtitle")}
onPress={this.props.resetPin}
onPress={this.props.requestIdentificationAndResetPin}
hideIcon={true}
/>

Expand Down Expand Up @@ -545,7 +546,22 @@ const mapStateToProps = (state: GlobalState) => ({
const mapDispatchToProps = (dispatch: Dispatch) => ({
// hard-logout
logout: () => dispatch(logoutRequest({ keepUserData: false })),
resetPin: () => dispatch(updatePin()),
requestIdentificationAndResetPin: () => {
const onSuccess = () => dispatch(updatePin());

return dispatch(
identificationRequest(
true,
false,
undefined,
undefined,
{
onSuccess
},
shufflePinPadOnPayment
)
);
},
clearCache: () => dispatch(clearCache()),
setDebugModeEnabled: (enabled: boolean) =>
dispatch(setDebugModeEnabled(enabled)),
Expand Down

0 comments on commit 7b01871

Please sign in to comment.