mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #3445 from TheCriw/i3440-seed-restore-trim-invalid-characters
improved verification of restore from seed phrase
This commit is contained in:
commit
34fe88af8f
@ -140,6 +140,19 @@ RestoreVaultScreen.prototype.createNewVaultAndRestore = function () {
|
|||||||
// check seed
|
// check seed
|
||||||
var seedBox = document.querySelector('textarea.twelve-word-phrase')
|
var seedBox = document.querySelector('textarea.twelve-word-phrase')
|
||||||
var seed = seedBox.value.trim()
|
var seed = seedBox.value.trim()
|
||||||
|
|
||||||
|
// true if the string has more than a space between words.
|
||||||
|
if (seed.split(' ').length > 1) {
|
||||||
|
this.warning = 'there can only a space between words'
|
||||||
|
this.props.dispatch(actions.displayWarning(this.warning))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// true if seed contains a character that is not between a-z or a space
|
||||||
|
if(!seed.match(/^[a-z ]+$/)) {
|
||||||
|
this.warning = 'seed words only have lowercase characters'
|
||||||
|
this.props.dispatch(actions.displayWarning(this.warning))
|
||||||
|
return
|
||||||
|
}
|
||||||
if (seed.split(' ').length !== 12) {
|
if (seed.split(' ').length !== 12) {
|
||||||
this.warning = 'seed phrases are 12 words long'
|
this.warning = 'seed phrases are 12 words long'
|
||||||
this.props.dispatch(actions.displayWarning(this.warning))
|
this.props.dispatch(actions.displayWarning(this.warning))
|
||||||
|
@ -144,6 +144,19 @@ RestoreVaultScreen.prototype.createNewVaultAndRestore = function () {
|
|||||||
// check seed
|
// check seed
|
||||||
var seedBox = document.querySelector('textarea.twelve-word-phrase')
|
var seedBox = document.querySelector('textarea.twelve-word-phrase')
|
||||||
var seed = seedBox.value.trim()
|
var seed = seedBox.value.trim()
|
||||||
|
|
||||||
|
// true if the string has more than a space between words.
|
||||||
|
if (seed.split(' ').length > 1) {
|
||||||
|
this.warning = 'there can only a space between words'
|
||||||
|
this.props.dispatch(actions.displayWarning(this.warning))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// true if seed contains a character that is not between a-z or a space
|
||||||
|
if(!seed.match(/^[a-z ]+$/)) {
|
||||||
|
this.warning = 'seed words only have lowercase characters'
|
||||||
|
this.props.dispatch(actions.displayWarning(this.warning))
|
||||||
|
return
|
||||||
|
}
|
||||||
if (seed.split(' ').length !== 12) {
|
if (seed.split(' ').length !== 12) {
|
||||||
this.warning = 'seed phrases are 12 words long'
|
this.warning = 'seed phrases are 12 words long'
|
||||||
this.props.dispatch(actions.displayWarning(this.warning))
|
this.props.dispatch(actions.displayWarning(this.warning))
|
||||||
|
Loading…
Reference in New Issue
Block a user