@@ -234,13 +234,21 @@ const Auth: React.FC<AuthProps> = ({
234
234
value : string ,
235
235
otpType : string ,
236
236
) => {
237
+ const createSuborgData : Record < string , any > = { } ;
238
+ if ( type === FilterType . Email ) createSuborgData . email = value ;
239
+ else if ( type === FilterType . PhoneNumber )
240
+ createSuborgData . phoneNumber = value ;
241
+ if ( customAccounts ) {
242
+ createSuborgData . customAccounts = customAccounts ;
243
+ }
237
244
const resp = await server . getOrCreateSuborg ( {
238
245
filterType : type ,
239
246
filterValue : value ,
247
+ additionalData : createSuborgData ,
240
248
} ) ;
241
249
const suborgIds = resp ?. subOrganizationIds ;
242
250
if ( ! suborgIds || suborgIds . length === 0 ) {
243
- onError ( authErrors . oauth . loginFailed ) ;
251
+ onError ( authErrors . otp . sendFailed ) ;
244
252
return ;
245
253
}
246
254
@@ -263,12 +271,16 @@ const Auth: React.FC<AuthProps> = ({
263
271
264
272
const handleOAuthLogin = async ( credential : string , providerName : string ) => {
265
273
setOauthLoading ( providerName ) ;
274
+ const createSuborgData : Record < string , any > = {
275
+ oauthProviders : [ { providerName, oidcToken : credential } ] ,
276
+ } ;
277
+ if ( customAccounts ) {
278
+ createSuborgData . customAccounts = customAccounts ;
279
+ }
266
280
const resp = await server . getOrCreateSuborg ( {
267
281
filterType : FilterType . OidcToken ,
268
282
filterValue : credential ,
269
- additionalData : {
270
- oauthProviders : [ { providerName, oidcToken : credential } ] ,
271
- } ,
283
+ additionalData : createSuborgData ,
272
284
} ) ;
273
285
const suborgIds = resp ?. subOrganizationIds ;
274
286
if ( ! suborgIds || suborgIds . length === 0 ) {
0 commit comments