From 2d1ec7c499df4dd5f46fe7c74ee8da5aa90535fc Mon Sep 17 00:00:00 2001 From: Debora Crescenzo Date: Fri, 2 Aug 2024 16:28:18 +0100 Subject: [PATCH] MT#60623 Hide features not covered by the license Following the changes about the licenses, some API will now return a "403 - License not available" error when the needed license is not available to the user. In the frontend we handle the licenses with two levels of protection: 1) We hide menus of missing licenses from the sidebar 2) We add a guard in boot/routes.js that would redirect to the homepage any attempts to access the mentioned menus, in case they are mistakenly shown. Change-Id: I9e88473ee90935db9b2a234ff03aef1b3a44a97b --- src/boot/routes.js | 9 ++++++- src/components/CscMainMenuTop.vue | 36 +++++++++++++++------------ src/constants.js | 9 +++++++ src/pages/CscPageConversations.vue | 40 +++++++++++++++++------------- src/pages/CscPageDashboard.vue | 6 ++--- src/router/routes.js | 11 +++++--- src/store/user.js | 3 +++ 7 files changed, 73 insertions(+), 41 deletions(-) diff --git a/src/boot/routes.js b/src/boot/routes.js index 944afd5d..24ac9e5f 100644 --- a/src/boot/routes.js +++ b/src/boot/routes.js @@ -34,7 +34,14 @@ export default ({ app, router, store }) => { break default: if (to.meta?.profileAttribute) { - store.getters['user/hasSubscriberProfileAttribute'](to.meta.profileAttribute) ? next() : next('/') + const hasSubscriberProfileAttribute = store.getters['user/hasSubscriberProfileAttribute'](to.meta.profileAttribute) + if (to.meta.license && hasSubscriberProfileAttribute) { + // Guard to assure that users cannot click on menu if + // it is mistakenly visible when the license is inactive + store.getters['user/isLicenseActive'](to.meta.profileAttribute) ? next() : next('/') + } + + hasSubscriberProfileAttribute ? next() : next('/') } else if (to.meta?.profileAttributes) { store.getters['user/hasSubscriberProfileAttributes'](to.meta.profileAttributes) ? next() : next('/') } else { diff --git a/src/components/CscMainMenuTop.vue b/src/components/CscMainMenuTop.vue index 06e4d4f0..0c30f85a 100644 --- a/src/components/CscMainMenuTop.vue +++ b/src/components/CscMainMenuTop.vue @@ -5,11 +5,9 @@