attempt empty pass without replacing input value
This commit is contained in:
parent
174dea8a29
commit
6a72d3ada9
|
@ -203,7 +203,12 @@ export class WalletDecrypt extends Component<Props, State> {
|
||||||
|
|
||||||
public state: State = {
|
public state: State = {
|
||||||
selectedWalletKey: null,
|
selectedWalletKey: null,
|
||||||
value: null,
|
value: {
|
||||||
|
key: '',
|
||||||
|
password: '',
|
||||||
|
valid: false,
|
||||||
|
attemptEmptyPass: false
|
||||||
|
},
|
||||||
hasAcknowledgedInsecure: false
|
hasAcknowledgedInsecure: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -424,7 +429,11 @@ export class WalletDecrypt extends Component<Props, State> {
|
||||||
// some components (TrezorDecrypt) don't take an onChange prop, and thus
|
// some components (TrezorDecrypt) don't take an onChange prop, and thus
|
||||||
// this.state.value will remain unpopulated. in this case, we can expect
|
// this.state.value will remain unpopulated. in this case, we can expect
|
||||||
// the payload to contain the unlocked wallet info.
|
// the payload to contain the unlocked wallet info.
|
||||||
const unlockValue = value && !isEmpty(value) ? value : payload;
|
const unlockValue =
|
||||||
|
value && !isEmpty(value)
|
||||||
|
? (value as PrivateKeyValue).attemptEmptyPass ? { ...value, password: '' } : value
|
||||||
|
: payload;
|
||||||
|
console.log(unlockValue);
|
||||||
this.WALLETS[selectedWalletKey].unlock(unlockValue);
|
this.WALLETS[selectedWalletKey].unlock(unlockValue);
|
||||||
this.props.resetTransactionState();
|
this.props.resetTransactionState();
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,7 @@ export interface KeystoreValue {
|
||||||
file: string;
|
file: string;
|
||||||
password: string;
|
password: string;
|
||||||
valid: boolean;
|
valid: boolean;
|
||||||
|
attemptEmptyPass: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPassRequired(file: string): boolean {
|
function isPassRequired(file: string): boolean {
|
||||||
|
@ -29,19 +30,21 @@ export class KeystoreDecrypt extends PureComponent {
|
||||||
public props: {
|
public props: {
|
||||||
value: KeystoreValue;
|
value: KeystoreValue;
|
||||||
isWalletPending: boolean;
|
isWalletPending: boolean;
|
||||||
isPasswordPending: boolean;
|
|
||||||
onChange(value: KeystoreValue): void;
|
onChange(value: KeystoreValue): void;
|
||||||
onUnlock(): void;
|
onUnlock(): void;
|
||||||
showNotification(level: string, message: string): TShowNotification;
|
showNotification(level: string, message: string): TShowNotification;
|
||||||
};
|
};
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const { isWalletPending, isPasswordPending, value: { file, password } } = this.props;
|
const { isWalletPending, value: { file, password } } = this.props;
|
||||||
const passReq = isPassRequired(file);
|
const passReq = isPassRequired(file);
|
||||||
const unlockDisabled = !file || (passReq && !password);
|
const unlockDisabled = !file || (passReq && !password);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form id="selectedUploadKey" onSubmit={this.unlock}>
|
<form id="selectedUploadKey" onSubmit={this.unlock}>
|
||||||
|
{isWalletPending ? (
|
||||||
|
<Spinner size="x2" />
|
||||||
|
) : (
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<input
|
<input
|
||||||
className={'hidden'}
|
className={'hidden'}
|
||||||
|
@ -49,13 +52,12 @@ export class KeystoreDecrypt extends PureComponent {
|
||||||
id="fselector"
|
id="fselector"
|
||||||
onChange={this.handleFileSelection}
|
onChange={this.handleFileSelection}
|
||||||
/>
|
/>
|
||||||
<label htmlFor="fselector" style={{ width: '100%' }}>
|
<label htmlFor="fselector" style={{ width: '100%', marginBottom: '0.5rem' }}>
|
||||||
<a className="btn btn-default btn-block" id="aria1" tabIndex={0} role="button">
|
<a className="btn btn-default btn-block" id="aria1" tabIndex={0} role="button">
|
||||||
{translate('ADD_Radio_2_short')}
|
{translate('ADD_Radio_2_short')}
|
||||||
</a>
|
</a>
|
||||||
</label>
|
</label>
|
||||||
{isWalletPending ? <Spinner /> : ''}
|
<div className={file.length ? '' : 'hidden'}>
|
||||||
<div className={file.length && isPasswordPending ? '' : 'hidden'}>
|
|
||||||
<p>{translate('ADD_Label_3')}</p>
|
<p>{translate('ADD_Label_3')}</p>
|
||||||
<input
|
<input
|
||||||
className={`form-control ${password.length > 0 ? 'is-valid' : 'is-invalid'}`}
|
className={`form-control ${password.length > 0 ? 'is-valid' : 'is-invalid'}`}
|
||||||
|
@ -66,11 +68,11 @@ export class KeystoreDecrypt extends PureComponent {
|
||||||
type="password"
|
type="password"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<button className="btn btn-primary btn-block" disabled={unlockDisabled}>
|
<button className="btn btn-primary btn-block" disabled={unlockDisabled}>
|
||||||
{translate('ADD_Label_6_short')}
|
{translate('ADD_Label_6_short')}
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</form>
|
</form>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -84,6 +86,10 @@ export class KeystoreDecrypt extends PureComponent {
|
||||||
private unlock = (e: React.SyntheticEvent<HTMLElement>) => {
|
private unlock = (e: React.SyntheticEvent<HTMLElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
this.props.onChange({
|
||||||
|
...this.props.value,
|
||||||
|
attemptEmptyPass: false
|
||||||
|
});
|
||||||
this.props.onUnlock();
|
this.props.onUnlock();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,7 +98,8 @@ export class KeystoreDecrypt extends PureComponent {
|
||||||
this.props.onChange({
|
this.props.onChange({
|
||||||
...this.props.value,
|
...this.props.value,
|
||||||
password: e.target.value,
|
password: e.target.value,
|
||||||
valid
|
valid,
|
||||||
|
attemptEmptyPass: false
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -109,7 +116,7 @@ export class KeystoreDecrypt extends PureComponent {
|
||||||
...this.props.value,
|
...this.props.value,
|
||||||
file: keystore,
|
file: keystore,
|
||||||
valid: keystore.length && !passReq,
|
valid: keystore.length && !passReq,
|
||||||
password: ''
|
attemptEmptyPass: true
|
||||||
});
|
});
|
||||||
this.props.onUnlock();
|
this.props.onUnlock();
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,7 @@ export interface PrivateKeyValue {
|
||||||
key: string;
|
key: string;
|
||||||
password: string;
|
password: string;
|
||||||
valid: boolean;
|
valid: boolean;
|
||||||
|
attemptEmptyPass: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Validated {
|
interface Validated {
|
||||||
|
|
Loading…
Reference in New Issue