MCPcopy Index your code
hub / github.com/simstudioai/sim / handleSubmit

Function handleSubmit

apps/sim/ee/sso/components/sso-settings.tsx:301–365  ·  view source on GitHub ↗
(e?: React.FormEvent)

Source from the content-addressed store, hash-verified

299 }
300
301 const handleSubmit = async (e?: React.FormEvent) => {
302 e?.preventDefault()
303
304 setShowErrors(true)
305 const validation = validateAll(formData)
306 if (hasAnyErrors(validation)) {
307 return
308 }
309
310 try {
311 const providerType = formData.providerType || 'oidc'
312
313 const requestBody: SsoRegistrationBody =
314 providerType === 'oidc'
315 ? {
316 providerType: 'oidc',
317 providerId: formData.providerId,
318 issuer: formData.issuerUrl,
319 domain: formData.domain,
320 orgId: activeOrganization?.id,
321 mapping: {
322 id: 'sub',
323 email: 'email',
324 name: 'name',
325 image: 'picture',
326 },
327 clientId: formData.clientId,
328 clientSecret: formData.clientSecret,
329 scopes: formData.scopes.split(',').map((s) => s.trim()),
330 }
331 : {
332 providerType: 'saml',
333 providerId: formData.providerId,
334 issuer: formData.issuerUrl,
335 domain: formData.domain,
336 orgId: activeOrganization?.id,
337 mapping: {
338 id: 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier',
339 email: 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress',
340 name: 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name',
341 },
342 entryPoint: formData.entryPoint,
343 cert: formData.cert,
344 wantAssertionsSigned: formData.wantAssertionsSigned,
345 ...(formData.callbackUrl ? { callbackUrl: formData.callbackUrl } : {}),
346 ...(formData.audience ? { audience: formData.audience } : {}),
347 ...(formData.idpMetadata ? { idpMetadata: formData.idpMetadata } : {}),
348 }
349
350 await configureSSOMutation.mutateAsync(requestBody)
351
352 logger.info('SSO provider configured', { providerId: formData.providerId })
353 toast.success(isEditing ? 'SSO provider updated' : 'SSO provider configured')
354 setFormData(DEFAULT_FORM_DATA)
355 setOriginalFormData(DEFAULT_FORM_DATA)
356 setErrors(DEFAULT_ERRORS)
357 setShowErrors(false)
358 setIsEditing(false)

Callers 1

SSOFunction · 0.70

Calls 5

getErrorMessageFunction · 0.90
validateAllFunction · 0.85
hasAnyErrorsFunction · 0.85
infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected