Browse Source

harden security, reset input fields

v0.25
pbca26 7 years ago
parent
commit
5388446978
  1. 13
      react/src/components/dashboard/importKeyModal/importKeyModal.js
  2. 11
      react/src/components/dashboard/importKeyModal/importKeyModal.render.js
  3. 45
      react/src/components/dashboard/settings/settings.exportKeysPanel.js
  4. 60
      react/src/components/login/login.js
  5. 4
      react/src/components/login/login.render.js
  6. 10
      react/src/components/overrides.scss

13
react/src/components/dashboard/importKeyModal/importKeyModal.js

@ -187,6 +187,19 @@ class ImportKeyModal extends React.Component {
); );
} }
}); });
this.state({
passphraseWif: null,
passphraseAddress: null,
wifkeysPassphrase: null,
wifkeysPassphraseTextarea: null,
importWithRescan: this.state.importWithRescan ? false : this.state.importWithRescan,
});
// reset input vals
this.refs.wif
this.refs.wifkeysPassphrase.value = '';
this.refs.wifkeysPassphraseTextarea.value = '';
} }
generateKeysFromPassphrase() { generateKeysFromPassphrase() {

11
react/src/components/dashboard/importKeyModal/importKeyModal.render.js

@ -26,23 +26,25 @@ export const ImportKeyModalRender = function() {
<strong>{ translate('IMPORT_KEY.NOTICE') }:</strong> { translate('IMPORT_KEY.NOTICE_DESC') }.&nbsp; <strong>{ translate('IMPORT_KEY.NOTICE') }:</strong> { translate('IMPORT_KEY.NOTICE_DESC') }.&nbsp;
<span className={ this.props.ActiveCoin.coin === 'KMD' ? '' : 'hide' }>{ translate('IMPORT_KEY.KMD_RESCAN_WARNING_TIME') }.</span> <span className={ this.props.ActiveCoin.coin === 'KMD' ? '' : 'hide' }>{ translate('IMPORT_KEY.KMD_RESCAN_WARNING_TIME') }.</span>
</p> </p>
<form <div
className="wifkeys-form" className="wifkeys-form"
method="post"
action="javascript:"
autoComplete="off"> autoComplete="off">
<div className="form-group form-material floating"> <div className="form-group form-material floating">
<input <input
autoComplete="off"
type="password" type="password"
className={ !this.state.seedInputVisibility ? 'form-control' : 'hide' } className={ !this.state.seedInputVisibility ? 'form-control' : 'hide' }
name="wifkeysPassphrase" name="wifkeysPassphrase"
id="wifkeysPassphrase" id="wifkeysPassphrase"
ref="wifkeysPassphrase"
onChange={ this.updateInput } onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase } /> value={ this.state.wifkeysPassphrase } />
<textarea <textarea
autoComplete="off"
className={ this.state.seedInputVisibility ? 'form-control' : 'hide' } className={ this.state.seedInputVisibility ? 'form-control' : 'hide' }
id="wifkeysPassphraseTextarea" id="wifkeysPassphraseTextarea"
name="wifkeysPassphrase" name="wifkeysPassphrase"
ref="wifkeysPassphraseTextarea"
onChange={ this.updateInput } onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase }></textarea> value={ this.state.wifkeysPassphrase }></textarea>
<i <i
@ -62,7 +64,7 @@ export const ImportKeyModalRender = function() {
className="btn btn-primary waves-effect waves-light" className="btn btn-primary waves-effect waves-light"
onClick={ this.showPassphraseAddress }>{ translate('IMPORT_KEY.SHOW_ADDRESS_AND_WIF') }</button> onClick={ this.showPassphraseAddress }>{ translate('IMPORT_KEY.SHOW_ADDRESS_AND_WIF') }</button>
</div> </div>
</form> </div>
{ this.state.passphraseAddress && { this.state.passphraseAddress &&
this.state.passphraseWif && this.state.passphraseWif &&
<div className="margin-top-60"> <div className="margin-top-60">
@ -118,6 +120,7 @@ export const ImportKeyModalRender = function() {
type="text" type="text"
className="form-control" className="form-control"
name="wif" name="wif"
ref="wif"
onChange={ this.updateInput } onChange={ this.updateInput }
value={ this.state.wif } /> value={ this.state.wif } />
</div> </div>

45
react/src/components/dashboard/settings/settings.exportKeysPanel.js

@ -28,7 +28,12 @@ class ExportKeysPanel extends React.Component {
props.Dashboard.activeSection !== 'settings') { props.Dashboard.activeSection !== 'settings') {
this.setState(Object.assign({}, this.state, { this.setState(Object.assign({}, this.state, {
keys: null, keys: null,
wifkeysPassphrase: '',
})); }));
// reset input vals
this.refs.wifkeysPassphrase.value = '';
this.refs.wifkeysPassphraseTextarea.value = '';
} }
} }
@ -46,8 +51,12 @@ class ExportKeysPanel extends React.Component {
} else { } else {
this.setState(Object.assign({}, this.state, { this.setState(Object.assign({}, this.state, {
keys: keys.result, keys: keys.result,
wifkeysPassphrase: '',
})); }));
console.warn(keys);
// reset input vals
this.refs.wifkeysPassphrase.value = '';
this.refs.wifkeysPassphraseTextarea.value = '';
} }
}) })
} }
@ -162,22 +171,24 @@ class ExportKeysPanel extends React.Component {
</div> </div>
<div className="row"> <div className="row">
<div className="col-sm-12"> <div className="col-sm-12">
<form <div
className="wifkeys-form" className="wifkeys-form"
method="post"
action="javascript:"
autoComplete="off"> autoComplete="off">
<div className="form-group form-material floating"> <div className="form-group form-material floating">
<input <input
type="password" type="password"
className={ !this.state.seedInputVisibility ? 'form-control' : 'hide' } className={ !this.state.seedInputVisibility ? 'form-control' : 'hide' }
autoComplete="off"
name="wifkeysPassphrase" name="wifkeysPassphrase"
ref="wifkeysPassphrase"
id="wifkeysPassphrase" id="wifkeysPassphrase"
onChange={ this.updateInput } onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase } /> value={ this.state.wifkeysPassphrase } />
<textarea <textarea
className={ this.state.seedInputVisibility ? 'form-control' : 'hide' } className={ this.state.seedInputVisibility ? 'form-control' : 'hide' }
autoComplete="off"
id="wifkeysPassphraseTextarea" id="wifkeysPassphraseTextarea"
ref="wifkeysPassphraseTextarea"
name="wifkeysPassphrase" name="wifkeysPassphrase"
onChange={ this.updateInput } onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase }></textarea> value={ this.state.wifkeysPassphrase }></textarea>
@ -191,25 +202,27 @@ class ExportKeysPanel extends React.Component {
<div className="col-sm-12 col-xs-12 text-align-center"> <div className="col-sm-12 col-xs-12 text-align-center">
<button <button
type="button" type="button"
className="btn btn-primary waves-effect waves-light" className="btn btn-primary waves-effect waves-light margin-bottom-5"
onClick={ this.exportWifKeys }>{ translate('INDEX.GET_WIF_KEYS') }</button> onClick={ this.exportWifKeys }>{ translate('INDEX.GET_WIF_KEYS') }</button>
</div> </div>
</form> </div>
</div> </div>
</div> </div>
{ this.state.keys && { this.state.keys &&
<div className="row"> <div className="row">
<div className="col-sm-12 padding-top-15"> <div className="col-sm-12 padding-top-15">
<table className="table"> <table className="table no-borders">
<tr key={ `wif-export-table-header-pub` }> <tbody>
<td className="padding-bottom-20 padding-top-20"> <tr key={ `wif-export-table-header-pub` }>
<strong>{ translate('SETTINGS.ADDRESS_LIST') }</strong> <td className="padding-bottom-20 padding-top-20">
</td> <strong>{ translate('SETTINGS.ADDRESS_LIST') }</strong>
<td className="padding-bottom-20 padding-top-20"> </td>
<strong>{ translate('SETTINGS.WIF_KEY_LIST') }</strong> <td className="padding-bottom-20 padding-top-20">
</td> <strong>{ translate('SETTINGS.WIF_KEY_LIST') }</strong>
</tr> </td>
{ this.renderWifKeys() } </tr>
{ this.renderWifKeys() }
</tbody>
</table> </table>
</div> </div>
</div> </div>

60
react/src/components/login/login.js

@ -8,7 +8,8 @@ import {
startInterval, startInterval,
getDexCoins, getDexCoins,
triggerToaster, triggerToaster,
toggleLoginSettingsModal toggleLoginSettingsModal,
stopInterval,
} from '../../actions/actionCreators'; } from '../../actions/actionCreators';
import Config from '../../config'; import Config from '../../config';
import Store from '../../store'; import Store from '../../store';
@ -197,6 +198,7 @@ class Login extends React.Component {
if (props.Login.pinList === 'no pins') { if (props.Login.pinList === 'no pins') {
props.Login.pinList = []; props.Login.pinList = [];
} }
if (props && if (props &&
props.Main && props.Main &&
props.Main.isLoggedIn) { props.Main.isLoggedIn) {
@ -215,21 +217,48 @@ class Login extends React.Component {
if (props && if (props &&
props.Main && props.Main &&
!props.Main.isLoggedIn) { !props.Main.isLoggedIn) {
document.body.className = 'page-login layout-full page-dark';
if (props.Interval &&
props.Interval.interval &&
props.Interval.interval.sync) {
Store.dispatch(
stopInterval(
'sync',
props.Interval.interval
)
);
}
this.setState({ this.setState({
display: true, display: true,
activeLoginSection: this.state.activeLoginSection !== 'signup' ? 'login' : 'signup', activeLoginSection: this.state.activeLoginSection !== 'signup' ? 'login' : 'signup',
}); });
}
if (props.Main &&
props.Main.total === 0) {
document.body.className = 'page-login layout-full page-dark'; document.body.className = 'page-login layout-full page-dark';
if (props.Interval &&
props.Interval.interval &&
props.Interval.interval.sync) {
Store.dispatch(
stopInterval(
'sync',
props.Interval.interval
)
);
}
} }
if (this.state.activeLoginSection !== 'signup' && if (this.state.activeLoginSection !== 'signup' &&
props && props &&
props.Main && props.Main &&
props.Main.isLoggedIn) { props.Main.isLoggedIn) {
this.setState({ this.setState({
activeLoginSection: 'activateCoin', activeLoginSection: 'activateCoin',
}); });
} }
} }
@ -286,12 +315,6 @@ class Login extends React.Component {
} }
loginSeed() { loginSeed() {
// reset the login pass phrase values so that when the user logs out, the values are clear
this.setState({
loginPassphrase: null,
loginPassPhraseSeedType: null,
});
if (this.state.shouldEncryptSeed) { if (this.state.shouldEncryptSeed) {
Store.dispatch(encryptPassphrase(this.state.loginPassphrase, this.state.encryptKey, this.state.pubKey)); Store.dispatch(encryptPassphrase(this.state.loginPassphrase, this.state.encryptKey, this.state.pubKey));
} }
@ -306,6 +329,16 @@ class Login extends React.Component {
shepherdElectrumCoins() shepherdElectrumCoins()
); );
} }
// reset the login pass phrase values so that when the user logs out, the values are clear
this.setState({
loginPassphrase: '',
loginPassPhraseSeedType: null,
});
// reset login input vals
this.refs.loginPassphrase.value = '';
this.refs.loginPassphraseEdit.value = '';
} }
loadPinList() { loadPinList() {
@ -362,13 +395,6 @@ class Login extends React.Component {
} }
execWalletCreate() { execWalletCreate() {
/*Store.dispatch(
createNewWallet(
this.state.randomSeedConfirm,
this.props.Dashboard.activeHandle
)
);*/
Store.dispatch( Store.dispatch(
shepherdElectrumAuth(this.state.randomSeedConfirm) shepherdElectrumAuth(this.state.randomSeedConfirm)
); );

4
react/src/components/login/login.render.js

@ -55,13 +55,17 @@ const LoginRender = function () {
type="password" type="password"
className={ !this.state.seedInputVisibility ? 'form-control' : 'hide' } className={ !this.state.seedInputVisibility ? 'form-control' : 'hide' }
name="loginPassphrase" name="loginPassphrase"
ref="loginPassphraseEdit"
onChange={ this.updateLoginPassPhraseInput } onChange={ this.updateLoginPassPhraseInput }
onKeyDown={ (event) => this.handleKeydown(event) } onKeyDown={ (event) => this.handleKeydown(event) }
autoComplete="off"
value={ this.state.loginPassphrase || '' } /> value={ this.state.loginPassphrase || '' } />
<textarea <textarea
className={ this.state.seedInputVisibility ? 'form-control' : 'hide' } className={ this.state.seedInputVisibility ? 'form-control' : 'hide' }
id="loginPassphrase" id="loginPassphrase"
ref="loginPassphrase"
name="loginPassphrase" name="loginPassphrase"
autoComplete="off"
onChange={ this.updateLoginPassPhraseInput } onChange={ this.updateLoginPassPhraseInput }
onKeyDown={ (event) => this.handleKeydown(event) } onKeyDown={ (event) => this.handleKeydown(event) }
value={ this.state.loginPassphrase || '' }></textarea> value={ this.state.loginPassphrase || '' }></textarea>

10
react/src/components/overrides.scss

@ -511,4 +511,14 @@ select{
.coind-remove-icon { .coind-remove-icon {
transform: rotate(45deg); transform: rotate(45deg);
top: 45px; top: 45px;
}
.coind-remove-icon-spv {
top: 19px;
}
.no-borders {
tbody > tr > td {
border: none;
}
} }
Loading…
Cancel
Save