Skip to content

Commit d9b85ef

Browse files
Harden LDAP config discovery during login
1 parent 843151c commit d9b85ef

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

ui/src/store/modules/user.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ const user = {
219219
commit('SET_PROJECT', {})
220220
commit('SET_HEADER_NOTICES', [])
221221
commit('SET_FEATURES', {})
222-
commit('SET_LDAP', {})
222+
commit('SET_LDAP', false)
223223
commit('SET_CLOUDIAN', {})
224224
commit('SET_DOMAIN_STORE', {})
225225
commit('SET_LOGOUT_FLAG', false)
@@ -268,7 +268,7 @@ const user = {
268268
commit('SET_PROJECT', {})
269269
commit('SET_HEADER_NOTICES', [])
270270
commit('SET_FEATURES', {})
271-
commit('SET_LDAP', {})
271+
commit('SET_LDAP', false)
272272
commit('SET_CLOUDIAN', {})
273273
commit('SET_DOMAIN_STORE', {})
274274
commit('SET_LOGOUT_FLAG', false)
@@ -420,9 +420,10 @@ const user = {
420420
})
421421

422422
api('listLdapConfigurations').then(response => {
423-
const ldapEnable = (response.ldapconfigurationresponse.count > 0)
423+
const ldapEnable = ((response && response.ldapconfigurationresponse && response.ldapconfigurationresponse.count) || 0) > 0
424424
commit('SET_LDAP', ldapEnable)
425425
}).catch(ignored => {
426+
commit('SET_LDAP', false)
426427
})
427428

428429
api('cloudianIsEnabled').then(response => {
@@ -447,7 +448,7 @@ const user = {
447448
commit('SET_PROJECT', {})
448449
commit('SET_HEADER_NOTICES', [])
449450
commit('SET_FEATURES', {})
450-
commit('SET_LDAP', {})
451+
commit('SET_LDAP', false)
451452
commit('SET_CLOUDIAN', {})
452453
commit('RESET_THEME')
453454
commit('SET_DOMAIN_STORE', {})
@@ -553,8 +554,9 @@ const user = {
553554
UpdateLdapConfigurationFlag ({ commit }) {
554555
return new Promise((resolve, reject) => {
555556
api('listLdapConfigurations').then(response => {
556-
const ldapEnable = (response.ldapconfigurationresponse.count > 0)
557+
const ldapEnable = ((response && response.ldapconfigurationresponse && response.ldapconfigurationresponse.count) || 0) > 0
557558
commit('SET_LDAP', ldapEnable)
559+
resolve(ldapEnable)
558560
}).catch(error => {
559561
reject(error)
560562
})

ui/src/utils/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const err = (error) => {
5151
})
5252
}
5353
if (response.status === 401) {
54-
if (response.config && response.config.params && ['forgotPassword', 'listIdps', 'cloudianIsEnabled'].includes(response.config.params.command)) {
54+
if (response.config && response.config.params && ['forgotPassword', 'listIdps', 'cloudianIsEnabled', 'listLdapConfigurations'].includes(response.config.params.command)) {
5555
return
5656
}
5757
const originalPath = router.currentRoute.value.fullPath

0 commit comments

Comments
 (0)