Skip to content

Commit d04f788

Browse files
committed
fix: update SSO configuration handling to correctly set SSO name and improve response parsing
1 parent e30bd41 commit d04f788

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Pages/GlobalConfigurations/Authorization/SSOLoginServices/SSOLogin.component.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,12 @@ class SSOLogin extends Component<SSOLoginProps & RouterV5Props<{}>, SSOLoginStat
150150
// keeping the existing type intact
151151
.then(([ssoConfigListRes, authorizationGlobalConfig]) => {
152152
let ssoConfig = ssoConfigListRes.result?.find((sso) => sso.active)
153+
let ssoName = 'google'
153154
if (ssoConfig) {
155+
ssoName = ssoConfig.name
154156
this.setState({ sso: ssoConfig?.name, lastActiveSSO: ssoConfig })
155157
} else {
156-
ssoConfig = sample.google.config as any // TODO: Add type for sample
158+
ssoConfig = sample.google as any // TODO: Add type for sample
157159
this.setState({ sso: 'google', ssoConfig: this.parseResponse(ssoConfig) })
158160
}
159161
// Would be undefined for OSS
@@ -165,20 +167,21 @@ class SSOLogin extends Component<SSOLoginProps & RouterV5Props<{}>, SSOLoginStat
165167
})
166168
this.savedShouldAutoAssignPermissionRef.current = shouldAutoAssignPermissions
167169
}
170+
return { ssoConfig, ssoName }
168171
})
169-
.then(() => {
170-
if (this.state.lastActiveSSO && this.state.lastActiveSSO?.id) {
171-
getSSOConfig(this.state.lastActiveSSO?.name.toLowerCase())
172+
.then(({ ssoConfig, ssoName }) => {
173+
if (ssoConfig?.id) {
174+
getSSOConfig(ssoConfig.name.toLowerCase())
172175
.then((response) => {
173-
this.setConfig(response, this.state.lastActiveSSO.name.toLowerCase())
176+
this.setConfig(response, ssoConfig.name.toLowerCase())
174177
})
175178
.catch((error) => {
176179
this.setState({ view: ViewType.ERROR, statusCode: error.code })
177180
})
178181
} else {
179182
this.setState({
180183
view: ViewType.FORM,
181-
ssoConfig: this.parseResponse(sample[this.state.sso]),
184+
ssoConfig: this.parseResponse(sample[ssoName]),
182185
})
183186
}
184187
})

0 commit comments

Comments
 (0)