Skip to content

Commit 67be3da

Browse files
authored
ui: fix create account/user with saml (apache#5481)
Fixes apache#5477 Fixes apache#5478 Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent d9154e8 commit 67be3da

File tree

3 files changed

+36
-28
lines changed

3 files changed

+36
-28
lines changed

ui/src/views/iam/AddAccount.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
v-decorator="['networkdomain']"
150150
:placeholder="apiParams.networkdomain.description" />
151151
</a-form-item>
152-
<div v-if="'authorizeSamlSso' in $store.getters.apis">
152+
<div v-if="samlAllowed">
153153
<a-form-item :label="$t('label.samlenable')">
154154
<a-switch v-decorator="['samlenable']" @change="checked => { this.samlEnable = checked }" />
155155
</a-form-item>
@@ -165,7 +165,7 @@
165165
:filterOption="(input, option) => {
166166
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
167167
}" >
168-
<a-select-option v-for="(idp, idx) in idps" :key="idx">
168+
<a-select-option v-for="idp in idps" :key="idp.id">
169169
{{ idp.orgName }}
170170
</a-select-option>
171171
</a-select>
@@ -217,12 +217,17 @@ export default {
217217
created () {
218218
this.fetchData()
219219
},
220+
computed: {
221+
samlAllowed () {
222+
return 'authorizeSamlSso' in this.$store.getters.apis
223+
}
224+
},
220225
methods: {
221226
fetchData () {
222227
this.fetchDomains()
223228
this.fetchRoles()
224229
this.fetchTimeZone()
225-
if ('listIdps' in this.$store.getters.apis) {
230+
if (this.samlAllowed) {
226231
this.fetchIdps()
227232
}
228233
},
@@ -344,7 +349,7 @@ export default {
344349
userid: users[i].id
345350
}).then(response => {
346351
this.$notification.success({
347-
message: this.$t('samlenable'),
352+
message: this.$t('label.samlenable'),
348353
description: this.$t('message.success.enable.saml.auth')
349354
})
350355
}).catch(error => {

ui/src/views/iam/AddUser.vue

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
</a-select-option>
141141
</a-select>
142142
</a-form-item>
143-
<div v-if="'authorizeSamlSso' in $store.getters.apis">
143+
<div v-if="samlAllowed">
144144
<a-form-item :label="$t('label.samlenable')">
145145
<a-switch v-decorator="['samlenable']" @change="checked => { this.samlEnable = checked }" />
146146
</a-form-item>
@@ -156,7 +156,7 @@
156156
:filterOption="(input, option) => {
157157
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
158158
}" >
159-
<a-select-option v-for="(idp, idx) in idps" :key="idx">
159+
<a-select-option v-for="idp in idps" :key="idp.id">
160160
{{ idp.orgName }}
161161
</a-select-option>
162162
</a-select>
@@ -208,6 +208,11 @@ export default {
208208
this.apiParams = this.$getApiParams('createUser', 'authorizeSamlSso')
209209
this.fetchData()
210210
},
211+
computed: {
212+
samlAllowed () {
213+
return 'authorizeSamlSso' in this.$store.getters.apis
214+
}
215+
},
211216
methods: {
212217
fetchData () {
213218
this.account = this.$route.query && this.$route.query.account ? this.$route.query.account : null
@@ -219,7 +224,7 @@ export default {
219224
this.fetchAccount()
220225
}
221226
this.fetchTimeZone()
222-
if ('listIdps' in this.$store.getters.apis) {
227+
if (this.samlAllowed) {
223228
this.fetchIdps()
224229
}
225230
},
@@ -318,26 +323,24 @@ export default {
318323
message: this.$t('label.create.user'),
319324
description: `${this.$t('message.success.create.user')} ${params.username}`
320325
})
321-
const users = response.createuserresponse.user.user
322-
if (values.samlenable && users) {
323-
for (var i = 0; i < users.length; i++) {
324-
api('authorizeSamlSso', {
325-
enable: values.samlenable,
326-
entityid: values.samlentity,
327-
userid: users[i].id
328-
}).then(response => {
329-
this.$notification.success({
330-
message: this.$t('label.samlenable'),
331-
description: this.$t('message.success.enable.saml.auth')
332-
})
333-
}).catch(error => {
334-
this.$notification.error({
335-
message: this.$t('message.request.failed'),
336-
description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message,
337-
duration: 0
338-
})
326+
const user = response.createuserresponse.user
327+
if (values.samlenable && user) {
328+
api('authorizeSamlSso', {
329+
enable: values.samlenable,
330+
entityid: values.samlentity,
331+
userid: user.id
332+
}).then(response => {
333+
this.$notification.success({
334+
message: this.$t('label.samlenable'),
335+
description: this.$t('message.success.enable.saml.auth')
336+
})
337+
}).catch(error => {
338+
this.$notification.error({
339+
message: this.$t('message.request.failed'),
340+
description: (error.response && error.response.headers && error.response.headers['x-description']) || error.message,
341+
duration: 0
339342
})
340-
}
343+
})
341344
}
342345
this.closeAction()
343346
}).catch(error => {

ui/src/views/iam/ConfigureSamlSsoAuth.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
<a-form-item :label="$t('label.samlentity')">
3232
<a-select
3333
v-decorator="['samlEntity', {
34-
initialValue: selectedIdp,
34+
initialValue: selectedIdp
3535
}]"
3636
showSearch
3737
optionFilterProp="children"
3838
:filterOption="(input, option) => {
3939
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
4040
}" >
41-
<a-select-option v-for="(idp, idx) in idps" :key="idx">
41+
<a-select-option v-for="idp in idps" :key="idp.id">
4242
{{ idp.orgName }}
4343
</a-select-option>
4444
</a-select>

0 commit comments

Comments
 (0)