Skip to content

Commit

Permalink
fix validate in more forms
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbitronics committed Jan 29, 2025
1 parent fe8516f commit 7192930
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/2sv/smartphone/VerifyQrCode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export default {
}),
methods: {
async verify() {
if (this.$refs.form.validate()) {
const { valid, errors } = await this.$refs.form.validate()
if (valid) {
try {
await verify(this.$route.query.id, this.code.trim())
Expand All @@ -67,6 +69,8 @@ export default {
this.errors.push(this.$t('2sv.smartphone.verifyQrCode.hint'))
}
}
} else {
throw Error(errors[0].errorMessages)
}
},
blur(event) {
Expand Down
5 changes: 4 additions & 1 deletion src/password/Confirm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,17 @@ export default {
},
methods: {
async confirm() {
if (this.$refs.form.validate()) {
const { valid, errors } = await this.$refs.form.validate()
if (valid) {
await this.$API.put('password', {
password: this.password,
})
this.$refs.wizard.completed()
this.$router.push('/password/saved')
} else {
throw Error(errors[0].errorMessages)
}
},
blur(event) {
Expand Down
6 changes: 5 additions & 1 deletion src/password/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ export default {
this.wizardKey += 1
},
async save() {
if (this.$refs.form.validate()) {
const { valid, errors } = await this.$refs.form.validate()
if (valid) {
try {
await this.$API.put('password/assess', {
password: this.password,
Expand All @@ -174,6 +176,8 @@ export default {
})
}
}
} else {
throw Error(errors[0].errorMessages)
}
},
blur(event) {
Expand Down
6 changes: 5 additions & 1 deletion src/password/Forgot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export default {
this.recaptchaResponse = ''
},
async send() {
if (this.$refs.form.validate()) {
const { valid, errors } = await this.$refs.form.validate()
if (valid) {
try {
const reset = await this.$API.post('reset', {
username: this.uname,
Expand All @@ -74,6 +76,8 @@ export default {
grecaptcha.reset()
throw error
}
} else {
throw Error(errors[0].errorMessages)
}
},
},
Expand Down

0 comments on commit 7192930

Please sign in to comment.