MT#60583 Amend Login API calls and 403 Invalid Licence err

We have introduced the concept of licenses which can be active
or inactive (all active licenses are stored in the array "licenses"
-GET 'api/platforminfo'). This means that a service (e.g. fax)
can be activated, but the license to use it could be active or
inactive. If the latter is true, the user is not allowed to
use the service in fact the backend returns a 403 - Invalid
license when the relevant endpoints are called.
* Before this commit we were retrieving the fax services as
part of the login phase, but with the new licenses logic the
existing flow was broken by a 403 for those users with inactive
fax license and it was impossible to login into the platform.
With this commit we amend getUserData() to wrap the call to
retrieve the fax settings in a statement that checks if the
fax licence is active.
* We edit the "Invalid license" message returned by the backend
with a more user-friendly text. The text is showed in a
small banner on top of the page every time the user opens
a page that is not supposed to access because the relevant
license is inactive.
* We remove some unused code in CscLayoutMain.vue
* v-if moved before class to silence warning in AuiMobileAppBadges

Change-Id: Ie7831e0024475c3a5aa8acf3874e6eda442fc9a2
(cherry picked from commit 98eee9c1ff)
mr12.5
Debora Crescenzo 9 months ago committed by Crescenzo Debora
parent e2fb2499e3
commit 732e154281

@ -168,12 +168,15 @@ export async function getList (options) {
function handleResponseError (err) {
const code = _.get(err, 'response.data.code', null)
const message = _.get(err, 'response.data.message', null)
let message = _.get(err, 'response.data.message', null)
if (code === 403 && message === 'Invalid license') {
message = 'Invalid or expired license. Contact your administrator to activate this functionality'
}
if (code !== null && message !== null) {
throw new ApiResponseError(err.response.data.code, err.response.data.message)
} else {
throw err
throw new ApiResponseError(code, message)
}
throw err
}
export async function get (options) {

@ -51,26 +51,30 @@ export async function loginByExchangeToken (token) {
}
}
export function getUserData (id) {
return new Promise((resolve, reject) => {
return Promise.all([
getSubscriberById(id),
getCapabilities(id),
getFaxServerSettings(id),
getResellerBranding(),
getPlatformInfo()
]).then(([subscriber, capabilities, faxServerSettings, resellerBranding, platformInfo]) => {
export async function getUserData (id) {
const allPromise = Promise.all([
getSubscriberById(id),
getCapabilities(id),
getResellerBranding(),
getPlatformInfo()
])
try {
const [subscriber, capabilities, resellerBranding, platformInfo] = await allPromise
if (capabilities.faxserver && platformInfo.licenses.find((license) => license === 'fax')) {
const faxServerSettings = await getFaxServerSettings(id)
capabilities.faxactive = faxServerSettings.active
resolve({
subscriber,
capabilities,
resellerBranding: resellerBranding?.items[0] || null,
platformInfo
})
}).catch((err) => {
reject(err)
})
})
}
return {
subscriber,
capabilities,
resellerBranding: resellerBranding?.items[0] || null,
platformInfo
}
} catch (error) {
throw new Error(error.response.data.message)
}
}
export function getSubscriberById (id) {

@ -1,7 +1,7 @@
<template>
<q-list
class="absolute-bottom"
v-if="appUrlAndroid || appUrlApple"
class="absolute-bottom"
dense
>
<q-item-label

@ -352,36 +352,12 @@ export default {
showQrBtn () {
return this.platformInfo?.app?.show_qr
},
hasCommunicationCapabilities () {
return (this.hasSmsCapability && this.hasSendSmsFeature) ||
(this.hasFaxCapabilityAndFaxActive && this.hasSendFaxFeature)
},
isMenuClosed () {
return !this.sideStates.left
},
isFullView () {
return this.isMenuClosed || this.isMobile || this.mobileMenu
},
layoutClasses () {
const classes = []
if (this.isCalling) {
classes.push('csc-layout-call-active')
}
if (this.menuMinimized) {
classes.push('csc-menu-minimized')
}
return classes
},
headerClasses () {
const classes = ['transition-generic']
if (this.isMobile) {
classes.push('csc-header-mobile')
}
if (this.isMobile || this.isMenuClosed) {
classes.push('csc-header-full')
}
return classes
},
pinMenuButtonIcon () {
if (!this.menuPinned) {
return 'push_pin'

Loading…
Cancel
Save