Skip to content

Commit

Permalink
Merge pull request #84 from ethereumproject/elaine/pw
Browse files Browse the repository at this point in the history
Fix some password issues
  • Loading branch information
elaineo authored Sep 14, 2017
2 parents 3822624 + f6477e0 commit c89ba97
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/components/wallet/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,21 @@ class WalletForm extends React.Component {
if (this.state.showTextKey)
this.props.openWallet(this.state.privKey, this.state.password)
.then((result) => {
if (typeof result === 'object')
if (!result instanceof Error) {
this.setState({ showBalance: true });
else
this.resetState();
} else
this.setState({ error: result });
});
else if (this.state.showRequirePass && this.state.showFileKey)
this.props.openWalletFile(this.state.file, this.state.password)
.then((result) => {
if (typeof result === 'object')
if (!result instanceof Error) {
this.setState({ showBalance: true });
else
this.setState({ error: result });
this.resetState();
} else
this.setState({ error: result.toString() });
});
this.resetState();
}

closeWallet = () => {
Expand Down Expand Up @@ -145,8 +146,9 @@ class WalletForm extends React.Component {
controlId="password"
>
<FormControl
componentClass="textarea"
componentClass="input"
placeholder="Password"
type="password"
bsSize="small"
onChange={this.handlePassword}
/>
Expand Down
7 changes: 6 additions & 1 deletion src/store/walletActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export function openWallet(key, password = null) {

export function openWalletFile(file, password = null) {
return (dispatch) => {
const wallet = Wallet.getWalletFromPrivKeyFile(file, password);
let wallet;
try { // TODO: Better error handling here
wallet = Wallet.getWalletFromPrivKeyFile(file, password);
} catch (e) {
return new Error(e);
}
const address = wallet.getAddressString();
dispatch({
type: 'WALLET/OPEN',
Expand Down

0 comments on commit c89ba97

Please sign in to comment.