1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Adjust private key confirmation style and logic.

This commit is contained in:
Kevin Serrano 2017-03-21 08:53:34 -07:00
parent a7b7be8309
commit 0e43606b16
3 changed files with 75 additions and 46 deletions

View File

@ -772,12 +772,19 @@ function requestExportAccount () {
} }
} }
function exportAccount (address) { function exportAccount (password, address) {
var self = this var self = this
return function (dispatch) { return function (dispatch) {
dispatch(self.showLoadingIndication()) dispatch(self.showLoadingIndication())
log.debug(`background.submitPassword`)
background.submitPassword(password, function (err) {
if (err) {
log.error('Error in submiting password.')
dispatch(self.hideLoadingIndication())
return dispatch(self.displayWarning('Incorrect Password.'))
}
log.debug(`background.exportAccount`) log.debug(`background.exportAccount`)
background.exportAccount(address, function (err, result) { background.exportAccount(address, function (err, result) {
dispatch(self.hideLoadingIndication()) dispatch(self.hideLoadingIndication())
@ -789,6 +796,7 @@ function exportAccount (address) {
dispatch(self.showPrivateKey(result)) dispatch(self.showPrivateKey(result))
}) })
})
} }
} }

View File

@ -4,14 +4,21 @@ const inherits = require('util').inherits
const copyToClipboard = require('copy-to-clipboard') const copyToClipboard = require('copy-to-clipboard')
const actions = require('../actions') const actions = require('../actions')
const ethUtil = require('ethereumjs-util') const ethUtil = require('ethereumjs-util')
const connect = require('react-redux').connect
module.exports = ExportAccountView module.exports = connect(mapStateToProps)(ExportAccountView)
inherits(ExportAccountView, Component) inherits(ExportAccountView, Component)
function ExportAccountView () { function ExportAccountView () {
Component.call(this) Component.call(this)
} }
function mapStateToProps (state) {
return {
warning: state.appState.warning,
}
}
ExportAccountView.prototype.render = function () { ExportAccountView.prototype.render = function () {
console.log('EXPORT VIEW') console.log('EXPORT VIEW')
console.dir(this.props) console.dir(this.props)
@ -28,12 +35,15 @@ ExportAccountView.prototype.render = function () {
if (notExporting) return h('div') if (notExporting) return h('div')
if (exportRequested) { if (exportRequested) {
var warning = `Exporting your private key is very dangerous, var warning = `Export private keys at your own risk.`
and you should only do it if you know what you're doing.`
var confirmation = `If you're absolutely sure, type "I understand" below and
submit.`
return ( return (
h('div', {
style: {
display: 'inline-block',
textAlign: 'center',
},
},
[
h('div', { h('div', {
key: 'exporting', key: 'exporting',
style: { style: {
@ -41,22 +51,41 @@ ExportAccountView.prototype.render = function () {
}, },
}, [ }, [
h('p.error', warning), h('p.error', warning),
h('p', confirmation),
h('input#exportAccount.sizing-input', { h('input#exportAccount.sizing-input', {
placeholder: 'confirm password',
onKeyPress: this.onExportKeyPress.bind(this), onKeyPress: this.onExportKeyPress.bind(this),
style: { style: {
position: 'relative', position: 'relative',
top: '1.5px', top: '1.5px',
marginBottom: '7px',
}, },
}), }),
]),
h('div', {
key: 'buttons',
style: {
margin: '0 20px',
},
},
[
h('button', { h('button', {
onClick: () => this.onExportKeyPress({ key: 'Enter', preventDefault: () => {} }), onClick: () => this.onExportKeyPress({ key: 'Enter', preventDefault: () => {} }),
style: {
marginRight: '10px',
},
}, 'Submit'), }, 'Submit'),
h('button', { h('button', {
onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)), onClick: () => this.props.dispatch(actions.backToAccountDetail(this.props.address)),
}, 'Cancel'), }, 'Cancel'),
]),
(this.props.warning) && (
h('span.error', {
style: {
margin: '20px',
},
}, this.props.warning.split('-'))
),
]) ])
) )
} }
@ -89,15 +118,6 @@ ExportAccountView.prototype.onExportKeyPress = function (event) {
if (event.key !== 'Enter') return if (event.key !== 'Enter') return
event.preventDefault() event.preventDefault()
var input = document.getElementById('exportAccount') var input = document.getElementById('exportAccount').value
if (input.value === 'I understand') { this.props.dispatch(actions.exportAccount(input, this.props.address))
this.props.dispatch(actions.exportAccount(this.props.address))
} else {
input.value = ''
input.placeholder = 'Please retype "I understand" exactly.'
}
}
ExportAccountView.prototype.exportAccount = function (address) {
this.props.dispatch(actions.exportAccount(address))
} }

View File

@ -266,8 +266,9 @@ app sections
} }
.sizing-input{ .sizing-input{
font-size: 1em; font-size: 14px;
height: 30px; height: 30px;
padding-left: 5px;
} }
.editable-label{ .editable-label{
display: flex; display: flex;