You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
3.7 KiB
149 lines
3.7 KiB
9 years ago
|
const inherits = require('util').inherits
|
||
|
|
||
|
const Component = require('react').Component
|
||
|
const connect = require('react-redux').connect
|
||
|
const h = require('react-hyperscript')
|
||
|
const actions = require('../actions')
|
||
|
|
||
|
module.exports = connect(mapStateToProps)(RevealSeedConfirmatoin)
|
||
|
|
||
|
inherits(RevealSeedConfirmatoin, Component)
|
||
9 years ago
|
function RevealSeedConfirmatoin () {
|
||
9 years ago
|
Component.call(this)
|
||
|
}
|
||
|
|
||
9 years ago
|
function mapStateToProps (state) {
|
||
9 years ago
|
return {
|
||
|
warning: state.appState.warning,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
RevealSeedConfirmatoin.prototype.confirmationPhrase = 'I understand'
|
||
|
|
||
9 years ago
|
RevealSeedConfirmatoin.prototype.render = function () {
|
||
9 years ago
|
const props = this.props
|
||
|
const state = this.state
|
||
|
|
||
|
return (
|
||
|
|
||
|
h('.initialize-screen.flex-column.flex-center.flex-grow', [
|
||
|
|
||
|
h('h3.flex-center.text-transform-uppercase', {
|
||
|
style: {
|
||
|
background: '#EBEBEB',
|
||
|
color: '#AEAEAE',
|
||
|
marginBottom: 24,
|
||
|
width: '100%',
|
||
|
fontSize: '20px',
|
||
|
padding: 6,
|
||
|
},
|
||
|
}, [
|
||
|
'Reveal Seed Words',
|
||
|
]),
|
||
|
|
||
|
h('.div', {
|
||
|
style: {
|
||
|
display: 'flex',
|
||
|
flexDirection: 'column',
|
||
|
padding: '20px',
|
||
|
justifyContent: 'center',
|
||
9 years ago
|
},
|
||
9 years ago
|
}, [
|
||
|
|
||
|
h('h4', 'Do not recover your seed words in a public place! These words can be used to steal all your accounts.'),
|
||
|
|
||
|
// confirmation
|
||
|
h('input.large-input.letter-spacey', {
|
||
|
type: 'password',
|
||
|
id: 'password-box',
|
||
|
placeholder: 'Enter your password to confirm',
|
||
|
onKeyPress: this.checkConfirmation.bind(this),
|
||
|
style: {
|
||
|
width: 260,
|
||
|
marginTop: '12px',
|
||
|
},
|
||
|
}),
|
||
|
|
||
9 years ago
|
h(`h4${state && state.confirmationWrong ? '.error' : ''}`, {
|
||
9 years ago
|
style: {
|
||
|
marginTop: '12px',
|
||
9 years ago
|
},
|
||
|
}, 'Enter the phrase "I understand" to proceed.'),
|
||
9 years ago
|
|
||
|
// confirm confirmation
|
||
|
h('input.large-input.letter-spacey', {
|
||
|
type: 'text',
|
||
|
id: 'confirm-box',
|
||
|
placeholder: this.confirmationPhrase,
|
||
|
onKeyPress: this.checkConfirmation.bind(this),
|
||
|
style: {
|
||
|
width: 260,
|
||
|
marginTop: 16,
|
||
|
},
|
||
|
}),
|
||
|
|
||
|
h('.flex-row.flex-space-between', {
|
||
|
style: {
|
||
|
marginTop: 30,
|
||
|
width: '50%',
|
||
|
},
|
||
|
}, [
|
||
|
// cancel
|
||
|
h('button.primary', {
|
||
|
onClick: this.goHome.bind(this),
|
||
|
}, 'CANCEL'),
|
||
|
|
||
|
// submit
|
||
|
h('button.primary', {
|
||
|
onClick: this.revealSeedWords.bind(this),
|
||
|
}, 'OK'),
|
||
|
|
||
|
]),
|
||
|
|
||
|
(props.warning) && (
|
||
|
h('span.error', {
|
||
|
style: {
|
||
|
margin: '20px',
|
||
9 years ago
|
},
|
||
9 years ago
|
}, props.warning.split('-'))
|
||
|
),
|
||
|
|
||
|
props.inProgress && (
|
||
|
h('span.in-progress-notification', 'Generating Seed...')
|
||
|
),
|
||
|
]),
|
||
|
])
|
||
|
)
|
||
|
}
|
||
|
|
||
9 years ago
|
RevealSeedConfirmatoin.prototype.componentDidMount = function () {
|
||
9 years ago
|
document.getElementById('password-box').focus()
|
||
|
}
|
||
|
|
||
9 years ago
|
RevealSeedConfirmatoin.prototype.goHome = function () {
|
||
9 years ago
|
this.props.dispatch(actions.showConfigPage(false))
|
||
|
}
|
||
|
|
||
|
// create vault
|
||
|
|
||
9 years ago
|
RevealSeedConfirmatoin.prototype.checkConfirmation = function (event) {
|
||
9 years ago
|
if (event.key === 'Enter') {
|
||
|
event.preventDefault()
|
||
|
this.revealSeedWords()
|
||
|
}
|
||
|
}
|
||
|
|
||
9 years ago
|
RevealSeedConfirmatoin.prototype.revealSeedWords = function () {
|
||
9 years ago
|
this.setState({ confirmationWrong: false })
|
||
|
|
||
|
const confirmBox = document.getElementById('confirm-box')
|
||
|
const confirmation = confirmBox.value
|
||
|
if (confirmation !== this.confirmationPhrase) {
|
||
|
confirmBox.value = ''
|
||
|
return this.setState({ confirmationWrong: true })
|
||
|
}
|
||
|
|
||
|
var password = document.getElementById('password-box').value
|
||
|
this.props.dispatch(actions.requestRevealSeed(password))
|
||
|
}
|