diff --git a/src/components/index/CreateModal.vue b/src/components/index/CreateModal.vue index 475c288..5eb2445 100644 --- a/src/components/index/CreateModal.vue +++ b/src/components/index/CreateModal.vue @@ -137,7 +137,10 @@ export default { }, validations() { return { - password: validation.password, + password: [ + validation.passwordRequired, + validation.passwordLength, + ], confirmPhrase: [ validation.required, matchConfirmPhrase diff --git a/src/components/index/RestoreModal.vue b/src/components/index/RestoreModal.vue index 18d8ad4..1e1af3d 100644 --- a/src/components/index/RestoreModal.vue +++ b/src/components/index/RestoreModal.vue @@ -104,7 +104,10 @@ export default { validation.required, helpers.withMessage('Invalid private key.', v => privateKeyRegexp.test(v)) ], - password: validation.password, + password: [ + validation.passwordRequired, + validation.passwordLength, + ], repeatPassword: [ helpers.withMessage('Passwords do not match.', sameAs(this.password)) ] diff --git a/src/components/index/UnlockModal.vue b/src/components/index/UnlockModal.vue index 9ba900f..37dc744 100644 --- a/src/components/index/UnlockModal.vue +++ b/src/components/index/UnlockModal.vue @@ -11,7 +11,7 @@ {{ address }} -
+
@@ -27,6 +27,7 @@ />
{{error.$message}}
+
{{passwordError}}
@@ -53,7 +54,6 @@ import { LockOpenIcon } from '@heroicons/vue/outline' import Modal from '../Modal' import useVuelidate from '@vuelidate/core' import { mapState } from 'vuex' -import { helpers } from '@vuelidate/validators' export default { name: 'CreateModal', @@ -64,16 +64,15 @@ export default { data() { return { password: '', + passwordError: '' } }, validations() { return { - password: [ - validation.passwordRequired, - helpers.withAsync(helpers.withMessage('Incorrect password.', this.checkPassword)) - ] + password: [validation.passwordRequired] } - }, props: { + }, + props: { afterUnlock: Function, close: Function, switchToForgetModal: Function, @@ -89,11 +88,20 @@ export default { } }, methods: { - checkPassword(input) { - return storage.comparePassword(input, this.walletVersion) + async checkPassword() { + this.v$.password.$reset() + if (await storage.comparePassword(this.password, this.walletVersion)) { + this.passwordError = '' + return true + } + else { + this.passwordError = 'Incorrect password.' + return false + } }, async unlock() { if (!await this.v$.$validate()) return + if (!await this.checkPassword()) return const privateKey = await storage.getPrivateKey(this.password, this.walletVersion) const publicKey = await storage.getPublicKey(this.walletVersion) diff --git a/src/components/tx/SellModal.vue b/src/components/tx/SellModal.vue index 43da3ef..2f70f4b 100644 --- a/src/components/tx/SellModal.vue +++ b/src/components/tx/SellModal.vue @@ -178,7 +178,7 @@