diff --git a/src/i18n/en.json b/src/i18n/en.json index 2b0c16f8..9b4bad5f 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -389,6 +389,7 @@ "Send Fax": "Send Fax", "Sending fax completed successfully.": "Sending fax completed successfully.", "Serial Ringing": "Serial Ringing", + "Session expired, please login again": "Session expired, please login again", "Set your PBX settings": "Set your PBX settings", "Set your fax settings": "Set your fax settings", "Set your personal alarm": "Set your personal alarm", diff --git a/src/pages/CscPageLogin.vue b/src/pages/CscPageLogin.vue index d08b7ad7..652c77a6 100644 --- a/src/pages/CscPageLogin.vue +++ b/src/pages/CscPageLogin.vue @@ -110,6 +110,8 @@ import CscInputPassword from 'components/form/CscInputPassword' import CscInput from 'components/form/CscInput' import CscRetrievePasswordDialog from 'components/CscRetrievePasswordDialog' import CscSelectionLanguage from 'components/CscSelectionLanguage' +import { deleteLocal, getLocal } from 'src/storage' +import { showToast } from 'src/helpers/ui' export default { name: 'Login', components: { @@ -155,6 +157,12 @@ export default { } } }, + mounted () { + if (getLocal('show_session_expired_msg')) { + showToast(this.$t('Session expired, please login again')) + deleteLocal('show_session_expired_msg') + } + }, methods: { login () { this.$store.dispatch('user/login', { diff --git a/src/store/user.js b/src/store/user.js index 48aecaac..050fefa3 100644 --- a/src/store/user.js +++ b/src/store/user.js @@ -25,6 +25,7 @@ import { qrPayload } from 'src/helpers/qr' import { date } from 'quasar' +import { setLocal } from 'src/storage' export default { namespaced: true, @@ -133,7 +134,7 @@ export default { jwtTTL (state) { const expirationBuffer = 0.05 try { - const jwtParts = state.jwt.split('.') + const jwtParts = getJwt().split('.') const jwtPayload = JSON.parse(atob(jwtParts[1])) if (_.isNumber(jwtPayload.exp)) { const timeDiff = Math.floor((Date.now() / 1000) - jwtPayload.exp) @@ -222,7 +223,6 @@ export default { }, userDataRequesting (state) { state.resellerBranding = null - state.userDataRequesting = true state.userDataSucceeded = false state.userDataError = null @@ -335,6 +335,7 @@ export default { context.commit('userDataSucceeded', userData) if (_.isNumber(context.getters.jwtTTL)) { setTimeout(() => { + setLocal('show_session_expired_msg', true) context.dispatch('logout') }, context.getters.jwtTTL * 1000) }