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 >
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 => {
0 commit comments