Skip to content

Commit

Permalink
fix: network key generation #80 (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Dec 17, 2020
1 parent 023fccf commit 1dd6551
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<v-text-field
v-model="zwave.networkKey"
label="Network Key"
:rules="[rules.validKey]"
:rules="[rules.validKey, rules.validLength]"
append-outer-icon="wifi_protected_setup"
@click:append-outer="randomKey"
></v-text-field>
Expand Down Expand Up @@ -564,10 +564,17 @@ export default {
'Name is not valid, only "a-z" "A-Z" "0-9" chars and "_" are allowed'
)
},
validKey: value => {
validLength: value => {
return (
!value || value.length === 32 || 'Key must be 32 charaters length'
)
},
validKey: value => {
return (
!value ||
!/[^A-F0-9]+/gi.test(value) ||
'Key not valid. Must contain only hex chars'
)
}
}
}
Expand All @@ -583,7 +590,7 @@ export default {
key += x.length === 2 ? x : '0' + x
}
this.zwave.networkKey = key
this.$set(this.zwave, 'networkKey', key)
},
readFile (file, callback) {
const reader = new FileReader()
Expand Down

0 comments on commit 1dd6551

Please sign in to comment.