toast by automatically logged out

This commit is contained in:
ogerly 2023-02-08 09:44:21 +01:00
parent 36e8e2c38d
commit c4fae48b1d
4 changed files with 23 additions and 1 deletions

View File

@ -67,6 +67,7 @@ export default {
}
if (this.tokenExpiresInSeconds === 0) {
this.$timer.stop('tokenExpires')
this.$store.commit('automaticallyLoggedOut', true)
this.$emit('logout')
}
},
@ -84,6 +85,7 @@ export default {
})
.catch(() => {
this.$timer.stop('tokenExpires')
this.$store.commit('automaticallyLoggedOut', true)
this.$emit('logout')
})
},

View File

@ -4,24 +4,33 @@ export const toasters = {
this.toast(message, {
title: this.$t('success'),
variant: 'success',
autoHideDelay: 5000,
})
},
toastError(message) {
this.toast(message, {
title: this.$t('error.error'),
variant: 'danger',
autoHideDelay: 5000,
})
},
toastInfo(message) {
this.toast(message, {
title: this.$t('navigation.info'),
variant: 'warning',
autoHideDelay: 5000,
})
},
toastInfoNoHide(message) {
this.toast(message, {
title: this.$t('navigation.info'),
variant: 'warning',
noAutoHide: true,
})
},
toast(message, options) {
if (message.replace) message = message.replace(/^GraphQL error: /, '')
this.$root.$bvToast.toast(message, {
autoHideDelay: 5000,
appendToast: true,
solid: true,
toaster: 'b-toaster-top-right',

View File

@ -123,5 +123,11 @@ export default {
return !this.showPageMessage
},
},
mounted() {
if (this.$store.state.automaticallyLoggedOut) {
this.toastInfoNoHide('Du wurdest automatisch abgemeldet')
this.$store.commit('automaticallyLoggedOut', false)
}
},
}
</script>

View File

@ -53,6 +53,9 @@ export const mutations = {
hideAmountGDT: (state, hideAmountGDT) => {
state.hideAmountGDT = !!hideAmountGDT
},
automaticallyLoggedOut: (state, automaticallyLoggedOut) => {
state.automaticallyLoggedOut = !!automaticallyLoggedOut
},
}
export const actions = {
@ -68,6 +71,7 @@ export const actions = {
commit('isAdmin', data.isAdmin)
commit('hideAmountGDD', data.hideAmountGDD)
commit('hideAmountGDT', data.hideAmountGDT)
commit('automaticallyLoggedOut', false)
},
logout: ({ commit, state }) => {
commit('token', null)
@ -108,6 +112,7 @@ try {
publisherId: null,
hideAmountGDD: null,
hideAmountGDT: null,
automaticallyLoggedOut: false,
},
getters: {},
// Syncronous mutation of the state