Fix PAT & Webauthn registration - Fixes #227

This commit is contained in:
Bubka 2023-09-14 13:39:48 +02:00
parent 43d7922732
commit a0b3b668bb
4 changed files with 14 additions and 6 deletions

View File

@ -88,13 +88,13 @@ router.beforeEach((to, from, next) => {
else if (to.name.startsWith('settings.')) { else if (to.name.startsWith('settings.')) {
if (to.params.returnTo == undefined) { if (to.params.returnTo == undefined) {
if (from.params.returnTo) { if (from.params.returnTo) {
next({name: to.name, params: { returnTo: from.params.returnTo }}) next({name: to.name, params: { ...to.params, returnTo: from.params.returnTo }})
} }
else if (from.name) { else if (from.name) {
next({name: to.name, params: { returnTo: from.path }}) next({name: to.name, params: { ...to.params, returnTo: from.path }})
} }
else { else {
next({name: to.name, params: { returnTo: '/accounts' }}) next({name: to.name, params: { ...to.params, returnTo: '/accounts' }})
} }
} }
else { else {

View File

@ -88,6 +88,14 @@
}); });
}, },
beforeRouteEnter(to, from, next) {
next(vm => {
if (from.params.returnTo) {
to.params.returnTo = from.params.returnTo
}
})
},
} }
</script> </script>

View File

@ -25,13 +25,13 @@
} }
}, },
props: ['id', 'name'], props: ['credentialId', 'name'],
methods: { methods: {
async updateCredential() { async updateCredential() {
await this.form.patch('/webauthn/credentials/' + this.id + '/name') await this.form.patch('/webauthn/credentials/' + this.credentialId + '/name')
if( this.form.errors.any() === false ) { if( this.form.errors.any() === false ) {
this.$notify({ type: 'is-success', text: this.$t('auth.webauthn.device_successfully_registered') }) this.$notify({ type: 'is-success', text: this.$t('auth.webauthn.device_successfully_registered') })

View File

@ -183,7 +183,7 @@
this.axios.post('/webauthn/register', publicKeyCredential, {returnError: true}) this.axios.post('/webauthn/register', publicKeyCredential, {returnError: true})
.then(response => { .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: { credentialId: publicKeyCredential.id, name: this.$t('auth.webauthn.my_device') } })
}) })
.catch(error => { .catch(error => {
if( error.response.status === 422 ) { if( error.response.status === 422 ) {