Skip to content

Commit 0e6d2d9

Browse files
authored
ui: prevent calling listConfigurations when not allowed (#11704)
By default, normal users won't have access to listConfigurations API, therefore, UI should not call it when access is not there. Signed-off-by: Abhishek Kumar <[email protected]>
1 parent db1c7d6 commit 0e6d2d9

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

ui/src/store/modules/user.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -539,14 +539,16 @@ const user = {
539539
reject(error)
540540
})
541541

542-
api('listConfigurations', { name: 'hypervisor.custom.display.name' }).then(json => {
543-
if (json.listconfigurationsresponse.configuration !== null) {
544-
const config = json.listconfigurationsresponse.configuration[0]
545-
commit('SET_CUSTOM_HYPERVISOR_NAME', config.value)
546-
}
547-
}).catch(error => {
548-
reject(error)
549-
})
542+
if ('listConfigurations' in store.getters.apis) {
543+
api('listConfigurations', { name: 'hypervisor.custom.display.name' }).then(json => {
544+
if (json.listconfigurationsresponse.configuration !== null) {
545+
const config = json.listconfigurationsresponse.configuration[0]
546+
commit('SET_CUSTOM_HYPERVISOR_NAME', config.value)
547+
}
548+
}).catch(error => {
549+
reject(error)
550+
})
551+
}
550552
})
551553
},
552554
UpdateConfiguration ({ commit }) {

ui/src/views/image/RegisterOrUploadTemplate.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,9 @@ export default {
646646
})
647647
},
648648
fetchCustomHypervisorName () {
649+
if (!('listConfigurations' in this.$store.getters.apis)) {
650+
return
651+
}
649652
const params = {
650653
name: 'hypervisor.custom.display.name'
651654
}

0 commit comments

Comments
 (0)