Unverified Commit a91eea4c authored by Valentine Wallace's avatar Valentine Wallace Committed by Tankred Hase

Desktop: ensure that during seed recovery, the user confirms their new password.

Previously, the user would only enter their new password once. Now, they enter it twice to confirm its correctness.
parent ccae1afd
......@@ -55,10 +55,6 @@ class NavAction {
this._navigate('RestoreSeed');
}
goRestorePin() {
this._navigate('RestorePin');
}
goSeedSuccess() {
this._navigate('SeedSuccess');
}
......
......@@ -29,10 +29,6 @@ class NavAction {
this._store.route = 'RestoreSeed';
}
goRestorePassword() {
this._store.route = 'RestorePassword';
}
goSeedSuccess() {
this._store.route = 'SeedSuccess';
}
......
......@@ -325,7 +325,7 @@ class WalletAction {
if (this._store.wallet.restoreIndex < 21) {
this._store.wallet.restoreIndex += 3;
} else {
this._nav.goRestorePassword();
this.initSetPassword();
}
}
......@@ -375,20 +375,6 @@ class WalletAction {
await this.unlockWallet({ walletPassword: password });
}
/**
* Initialize the wallet with the password input the seed that was already
* inputted, and the default recovery window.
* @return {Promise<undefined>}
*/
async restoreWallet() {
const { password, restoreSeed } = this._store.wallet;
await this.initWallet({
walletPassword: password,
seedMnemonic: restoreSeed.toJSON(),
recoveryWindow: RECOVERY_WINDOW,
});
}
/**
* Unlock the wallet by calling the grpc api with the user chosen password.
* @param {string} options.walletPassword The password used to encrypt the wallet
......
......@@ -11,7 +11,6 @@ import SeedSuccess from './seed-success';
import SetPassword from './set-password';
import SetPasswordConfirm from './set-password-confirm';
import RestoreSeed from './restore-seed';
import RestorePassword from './restore-password';
import Password from './password';
import ResetPasswordCurrent from './reset-password-current';
import ResetPasswordNew from './reset-password-new';
......@@ -83,9 +82,6 @@ class MainView extends Component {
{route === 'RestoreSeed' && (
<RestoreSeed store={store} wallet={wallet} />
)}
{route === 'RestorePassword' && (
<RestorePassword store={store} wallet={wallet} nav={nav} />
)}
{route === 'Password' && <Password store={store} wallet={wallet} />}
{route === 'ResetPasswordCurrent' && (
<ResetPasswordCurrent store={store} nav={nav} wallet={wallet} />
......
import React from 'react';
import { StyleSheet } from 'react-native';
import { observer } from 'mobx-react';
import PropTypes from 'prop-types';
import { SplitBackground } from '../component/background';
import MainContent from '../component/main-content';
import { H1Text } from '../component/text';
import { Header } from '../component/header';
import { Button, BackButton, GlasButton } from '../component/button';
import { PasswordCard } from '../component/password-entry';
import { color } from '../component/style';
//
// Restore Wallet Password View
//
const styles = StyleSheet.create({
content: {
justifyContent: 'flex-end',
},
title: {
textAlign: 'center',
marginBottom: 20,
},
});
const RestorePasswordView = ({ store, wallet, nav }) => (
<SplitBackground image="purple-gradient-bg" bottom={color.blackDark}>
<Header>
<BackButton onPress={() => nav.goSelectSeed()} />
<Button disabled onPress={() => {}} />
</Header>
<MainContent style={styles.content}>
<H1Text style={styles.title}>Restore wallet</H1Text>
<PasswordCard
copy="Please enter your password."
placeholder="Password"
password={store.wallet.password}
onChangeText={password => wallet.setPassword({ password })}
onSubmitEditing={() => wallet.restoreWallet()}
/>
<GlasButton onPress={() => wallet.restoreWallet()}>Restore</GlasButton>
</MainContent>
</SplitBackground>
);
RestorePasswordView.propTypes = {
store: PropTypes.object.isRequired,
wallet: PropTypes.object.isRequired,
nav: PropTypes.object.isRequired,
};
export default observer(RestorePasswordView);
......@@ -73,7 +73,6 @@ import SetPasswordConfirm from '../src/view/set-password-confirm';
import SetPinConfirmMobile from '../src/view/set-pin-confirm-mobile';
import Password from '../src/view/password';
import PinMobile from '../src/view/pin-mobile';
import RestorePassword from '../src/view/restore-password';
import ResetPasswordCurrent from '../src/view/reset-password-current';
import ResetPasswordNew from '../src/view/reset-password-new';
import ResetPasswordConfirm from '../src/view/reset-password-confirm';
......@@ -155,9 +154,6 @@ storiesOf('Screens', module)
))
.add('Password', () => <Password store={store} wallet={wallet} />)
.add('PIN (Mobile)', () => <PinMobile store={store} auth={auth} />)
.add('Restore Wallet: Password', () => (
<RestorePassword store={store} wallet={wallet} nav={nav} />
))
.add('Reset Password - Current', () => (
<ResetPasswordCurrent store={store} wallet={wallet} nav={nav} />
))
......
......@@ -81,13 +81,6 @@ describe('Action Nav Unit Tests', () => {
});
});
describe('goRestorePassword()', () => {
it('should set correct route', () => {
nav.goRestorePassword();
expect(store.route, 'to equal', 'RestorePassword');
});
});
describe('goNewAddress()', () => {
it('should set correct route', () => {
nav.goNewAddress();
......
......@@ -387,14 +387,14 @@ describe('Action Wallet Unit Tests', () => {
it('should navigate to password screen if restoreIndex > 20', () => {
store.wallet.restoreIndex = 21;
wallet.initNextRestorePage();
expect(nav.goRestorePassword, 'was called once');
expect(nav.goSetPassword, 'was called once');
expect(store.wallet.restoreIndex, 'to equal', 21);
});
it('should increment restoreIndex if less than 21', async () => {
store.wallet.restoreIndex = 18;
wallet.initNextRestorePage();
expect(nav.goRestorePassword, 'was not called');
expect(nav.goSetPassword, 'was not called');
expect(store.wallet.restoreIndex, 'to equal', 21);
});
});
......@@ -469,24 +469,6 @@ describe('Action Wallet Unit Tests', () => {
});
});
describe('restoreWallet()', () => {
beforeEach(() => {
sandbox.stub(wallet, 'initWallet');
});
it('calls initWallet with password and restoreSeed', async () => {
wallet.setPassword({ password: 'secret123' });
const seed = Array(24).fill('foo');
store.wallet.restoreSeed = seed;
await wallet.restoreWallet();
expect(wallet.initWallet, 'was called with', {
walletPassword: 'secret123',
seedMnemonic: seed,
recoveryWindow: RECOVERY_WINDOW,
});
});
});
describe('unlockWallet()', () => {
it('should unlock wallet', async () => {
grpc.sendUnlockerCommand.withArgs('UnlockWallet').resolves();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment