Skip to content

Commit 27bbaa1

Browse files
andreabadessor4mmer
authored andcommitted
fix: error in biometry migration
1 parent 23bc594 commit 27bbaa1

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/sagas/wallet.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import {
7272
firstAddressFailure,
7373
firstAddressSuccess,
7474
setUseSafeBiometryMode,
75+
lockScreen,
7576
} from '../actions';
7677
import { fetchTokenData } from './tokens';
7778
import {
@@ -437,8 +438,8 @@ export function* onPushNotificationDisabled() {
437438
}
438439

439440
export function* onSafeBiometryToggleChanged() {
440-
log.debug('Safe biometry mode feature toggle changed state, reloading wallet.');
441-
yield put(reloadWalletRequested());
441+
log.debug('Safe biometry mode feature toggle changed state, locking wallet.');
442+
yield put(lockScreen());
442443
}
443444

444445
/**

src/screens/PinScreen.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,18 @@ class PinScreen extends React.Component {
147147
if (this.props.isLockScreen) {
148148
// in case it's the lock screen, we just have to execute the data migration
149149
// method an change redux state. No need to execute callback or go back on navigation
150+
console.log('inside dismiss');
150151
await STORE.handleDataMigration(pin);
151-
await biometricsMigration(pin, this.props.safeBiometryEnabled);
152+
console.log('Will call biometricsMigration');
153+
const newPin = await biometricsMigration(pin, this.props.safeBiometryEnabled);
154+
console.log('Done migrating biometrics.');
152155
if (!this.props.wallet) {
153156
// We have already made sure we have an available accessData
154157
// The handleDataMigration method ensures we have already migrated if necessary
155158
// This means the wallet is loaded and the access data is ready to be used.
156159

157-
const words = await STORE.getWalletWords(pin);
158-
this.props.startWalletRequested({ words, pin });
160+
const words = await STORE.getWalletWords(newPin);
161+
this.props.startWalletRequested({ words, pin: newPin });
159162
}
160163
this.props.unlockScreen();
161164
} else {

src/utils.js

+15
Original file line numberDiff line numberDiff line change
@@ -102,29 +102,44 @@ export async function biometricsMigration(currentPassword, safeBiometryEnabled)
102102
const safeBiometry = STORE.getItem(IS_BIOMETRY_ENABLED_KEY);
103103

104104
if (safeBiometryEnabled) {
105+
console.log('Safe biometry enabled.');
105106
// Safe biometry mode, need to migrate if old biometry is enabled.
106107
if (oldBiometry) {
108+
console.log('old biometry');
107109
// currentPassword is the pin, we need to generate a new random password
108110
// and encrypt the pin.
109111
const password = generateRandomPassword();
110112
const storage = STORE.getStorage();
111113
await changePinOnAccessData(storage, currentPassword, password);
114+
console.log('Changed pin on access data.');
112115
STORE.enableSafeBiometry(currentPassword, password);
113116
STORE.removeItem(IS_OLD_BIOMETRY_ENABLED_KEY);
117+
118+
return password;
114119
}
115120
} else {
121+
console.log('Safe biometry disabled');
116122
// Old biometry mode, need to migrate if safe biometry is enabled.
117123
// eslint-disable-next-line no-lonely-if
118124
if (safeBiometry) {
125+
console.log('Will migrate to safe biometry');
119126
// currentPassword is the random password, we need to decrypt the pin and
120127
// toggle the old biometry key
121128
const pin = STORE.disableSafeBiometry(currentPassword);
129+
console.log('got pin', pin);
122130
const storage = STORE.getStorage();
131+
console.log('got storage');
123132
await changePinOnAccessData(storage, currentPassword, pin);
133+
console.log('Changed pin on access data.');
124134
STORE.removeItem(IS_BIOMETRY_ENABLED_KEY);
125135
STORE.setItem(IS_OLD_BIOMETRY_ENABLED_KEY, true);
136+
137+
return pin;
126138
}
127139
}
140+
141+
console.log('Done.');
142+
return currentPassword;
128143
}
129144

130145
/**

0 commit comments

Comments
 (0)