Skip to content

Commit

Permalink
fix(suite-native): ensure that passphrase retry flow finishes correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
yanascz committed Nov 22, 2024
1 parent 04c428a commit 1dd1137
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions suite-native/device-authorization/src/passphraseThunks.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createThunk } from '@suite-common/redux-utils';
import {
authorizeDeviceThunk,
deviceActions,
selectDevice,
selectDeviceThunk,
selectDevices,
createDeviceInstanceThunk,
} from '@suite-common/wallet-core';
import TrezorConnect from '@trezor/connect';

Expand Down Expand Up @@ -85,10 +85,20 @@ export const verifyPassphraseOnEmptyWalletThunk = createThunk<

export const retryPassphraseAuthenticationThunk = createThunk(
`${PASSPHRASE_MODULE_PREFIX}/retryPassphraseAuthentication`,
(_, { dispatch, getState }) => {
(_, { dispatch, getState, extra }) => {
const device = selectDevice(getState());

if (!device) return;
dispatch(authorizeDeviceThunk({ shouldIgnoreDeviceState: true }));

const settings = extra.selectors.selectSuiteSettings(getState());

// Remove device on which the passphrase flow was restarted
dispatch(deviceActions.forgetDevice({ device, settings }));

const newDevice = selectDevice(getState());

if (!newDevice) return;

dispatch(createDeviceInstanceThunk({ device: newDevice, useEmptyPassphrase: false }));
},
);

0 comments on commit 1dd1137

Please sign in to comment.