Skip to content

Commit 63496c5

Browse files
committed
ui: prevent calling listConfigurations when not allowed
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 db5b6a5 commit 63496c5

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
@@ -532,14 +532,16 @@ const user = {
532532
reject(error)
533533
})
534534

535-
api('listConfigurations', { name: 'hypervisor.custom.display.name' }).then(json => {
536-
if (json.listconfigurationsresponse.configuration !== null) {
537-
const config = json.listconfigurationsresponse.configuration[0]
538-
commit('SET_CUSTOM_HYPERVISOR_NAME', config.value)
539-
}
540-
}).catch(error => {
541-
reject(error)
542-
})
535+
if ('listConfigurations' in store.getters.apis) {
536+
api('listConfigurations', { name: 'hypervisor.custom.display.name' }).then(json => {
537+
if (json.listconfigurationsresponse.configuration !== null) {
538+
const config = json.listconfigurationsresponse.configuration[0]
539+
commit('SET_CUSTOM_HYPERVISOR_NAME', config.value)
540+
}
541+
}).catch(error => {
542+
reject(error)
543+
})
544+
}
543545
})
544546
},
545547
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)