MT#63513 this.$router.push bugfix

On initUser the app tries to push items the
router before it is initialized, which results
in the error "Can't access property push,
this.$router is undefined". We add optional
chaining to prevent this from happening.

Change-Id: I6e2bf6336c8e91682962154219fc1c0bc1dbeacb
master
Debora Crescenzo 1 month ago
parent abc25dc49c
commit 88aacb7fcb

@ -150,7 +150,7 @@ function handleResponseError (err) {
} }
if (code === 403 && message === 'Password expired') { if (code === 403 && message === 'Password expired') {
message = i18n.global.t('Password Expired') message = i18n.global.t('Password Expired')
return this.$router.push({ path: PATH_CHANGE_PASSWORD }) return this.$router?.push({ path: PATH_CHANGE_PASSWORD })
} }
if (code !== null && message !== null) { if (code !== null && message !== null) {

@ -256,7 +256,7 @@ export default {
}) })
}, },
jumpToCallQueue (context, subscriber) { jumpToCallQueue (context, subscriber) {
this.$router.push({ path: '/user/pbx-configuration/call-queues' }) this.$router?.push({ path: '/user/pbx-configuration/call-queues' })
context.commit('expandCallQueue', subscriber.id) context.commit('expandCallQueue', subscriber.id)
} }
} }

@ -242,7 +242,7 @@ export default {
}) })
}, },
jumpToMsConfig (context, subscriber) { jumpToMsConfig (context, subscriber) {
this.$router.push({ path: '/user/pbx-configuration/ms-configs' }) this.$router?.push({ path: '/user/pbx-configuration/ms-configs' })
context.commit('expandMsConfig', subscriber.id) context.commit('expandMsConfig', subscriber.id)
} }
} }

@ -391,7 +391,7 @@ export default {
subscriberId: getSubscriberId() subscriberId: getSubscriberId()
}) })
await context.dispatch('initUser') await context.dispatch('initUser')
await this.$router.push({ name: 'dashboard' }) await this.$router?.push({ name: 'dashboard' })
} catch (err) { } catch (err) {
if (err.message === 'Invalid OTP') { if (err.message === 'Invalid OTP') {
if (context.state.loginWaitingOTPCode) { if (context.state.loginWaitingOTPCode) {
@ -405,7 +405,7 @@ export default {
} }
context.commit('loginFailed', err.message) context.commit('loginFailed', err.message)
if (err.message === 'Password expired') { if (err.message === 'Password expired') {
this.$router.push({ path: PATH_CHANGE_PASSWORD }) this.$router?.push({ path: PATH_CHANGE_PASSWORD })
} else if (err.message === 'Banned') { } else if (err.message === 'Banned') {
context.commit('loginFailed', i18n.global.t('There is a problem with your account, please contact support')) context.commit('loginFailed', i18n.global.t('There is a problem with your account, please contact support'))
} }

Loading…
Cancel
Save