Add authentication followup to front-end to ease navigation & redirects

This commit is contained in:
Bubka
2023-08-04 15:13:30 +02:00
parent afd020019b
commit a80a002ce7
5 changed files with 26 additions and 6 deletions

View File

@ -81,10 +81,13 @@
this.form.post('/user/login', {returnError: true})
.then(response => {
this.applyPreferences(response.data.preferences);
this.$storage.set('authenticated', true)
this.applyPreferences(response.data.preferences)
this.$router.push({ name: 'accounts', params: { toRefresh: true } })
})
.catch(error => {
this.$storage.set('authenticated', false)
if( error.response.status === 401 ) {
this.$notify({ type: 'is-danger', text: this.$t('auth.forms.authentication_failed'), duration:-1 })
@ -142,12 +145,15 @@
publicKeyCredential.email = this.form.email
this.axios.post('/webauthn/login', publicKeyCredential, {returnError: true}).then(response => {
this.$storage.set('authenticated', true)
this.applyPreferences(response.data.preferences);
this.$router.push({ name: 'accounts', params: { toRefresh: true } })
})
.catch(error => {
if( error.response.status === 401 ) {
this.$storage.set('authenticated', false)
if( error.response.status === 401 ) {
this.$notify({ type: 'is-danger', text: this.$t('auth.forms.authentication_failed'), duration:-1 })
}
else if( error.response.status !== 422 ) {

View File

@ -71,6 +71,7 @@
this.registerForm.post('/user', {returnError: true})
.then(response => {
this.$storage.set('authenticated', true)
this.showWebauthnRegistration = true
})
.catch(error => {