Handle Validation errors from webauthn during device registration (#200)

This commit is contained in:
Bubka 2023-07-05 10:07:40 +02:00
parent aed5956b23
commit 085eb25532
2 changed files with 20 additions and 2 deletions

View File

@ -117,10 +117,19 @@
const publicKeyCredential = this.webauthn.parseOutgoingCredentials(bufferedCredentials); const publicKeyCredential = this.webauthn.parseOutgoingCredentials(bufferedCredentials);
this.axios.post('/webauthn/register', publicKeyCredential).then(response => { this.axios.post('/webauthn/register', publicKeyCredential, {returnError: true})
.then(response => {
this.deviceId = publicKeyCredential.id this.deviceId = publicKeyCredential.id
this.deviceRegistered = true this.deviceRegistered = true
}) })
.catch(error => {
if( error.response.status === 422 ) {
this.$notify({ type: 'is-danger', text: error.response.data.message })
}
else {
this.$router.push({ name: 'genericError', params: { err: error.response } });
}
})
}, },

View File

@ -172,9 +172,18 @@
const publicKeyCredential = this.webauthn.parseOutgoingCredentials(bufferedCredentials); const publicKeyCredential = this.webauthn.parseOutgoingCredentials(bufferedCredentials);
this.axios.post('/webauthn/register', publicKeyCredential).then(response => { this.axios.post('/webauthn/register', publicKeyCredential, {returnError: true})
.then(response => {
this.$router.push({ name: 'settings.webauthn.editCredential', params: { id: publicKeyCredential.id, name: this.$t('auth.webauthn.my_device') } }) this.$router.push({ name: 'settings.webauthn.editCredential', params: { id: publicKeyCredential.id, name: this.$t('auth.webauthn.my_device') } })
}) })
.catch(error => {
if( error.response.status === 422 ) {
this.$notify({ type: 'is-danger', text: error.response.data.message })
}
else {
this.$router.push({ name: 'genericError', params: { err: error.response } });
}
})
}, },