@@ -337,58 +337,40 @@ <h1 class="title">Module <code>supertokens_python.recipe.dashboard.utils</code><
337337 recipe: Optional[str] = None
338338
339339 async def update_user_dict(
340- get_user_func1: Callable[[str], Awaitable[GetUserResult]],
341- get_user_func2: Callable[[str], Awaitable[GetUserResult]],
342- recipe1: str,
343- recipe2: str,
340+ get_user_funcs: List[Callable[[str], Awaitable[GetUserResult]]],
341+ recipes: List[str],
344342 ):
345343 nonlocal user, user_id, recipe
346344
347- try:
348- recipe_user = await get_user_func1(user_id) # type: ignore
349-
350- if recipe_user is not None:
351- user = UserWithMetadata().from_dict(
352- recipe_user.__dict__, first_name="", last_name=""
353- )
354- recipe = recipe1
355- except Exception:
356- pass
357-
358- if user is None:
345+ for get_user_func, recipe_id in zip(get_user_funcs, recipes):
359346 try:
360- recipe_user = await get_user_func2 (user_id)
347+ recipe_user = await get_user_func (user_id) # type: ignore
361348
362349 if recipe_user is not None:
363350 user = UserWithMetadata().from_dict(
364351 recipe_user.__dict__, first_name="", last_name=""
365352 )
366- recipe = recipe2
353+ recipe = recipe_id
354+ break
367355 except Exception:
368356 pass
369357
370358 if recipe_id == EmailPasswordRecipe.recipe_id:
371359 await update_user_dict(
372- ep_get_user_by_id,
373- tpep_get_user_by_id,
374- "emailpassword",
375- "thirdpartyemailpassword",
360+ [ep_get_user_by_id, tpep_get_user_by_id],
361+ ["emailpassword", "thirdpartyemailpassword"],
376362 )
377363
378364 elif recipe_id == ThirdPartyRecipe.recipe_id:
379365 await update_user_dict(
380- tp_get_user_by_idx,
381- tpep_get_user_by_id,
382- "thirdparty",
383- "thirdpartyemailpassword",
366+ [tp_get_user_by_idx, tpep_get_user_by_id, tppless_get_user_by_id],
367+ ["thirdparty", "thirdpartyemailpassword", "thirdpartypasswordless"],
384368 )
385369
386370 elif recipe_id == PasswordlessRecipe.recipe_id:
387371 await update_user_dict(
388- pless_get_user_by_id,
389- tppless_get_user_by_id,
390- "passwordless",
391- "thirdpartypasswordless",
372+ [pless_get_user_by_id, tppless_get_user_by_id],
373+ ["passwordless", "thirdpartypasswordless"],
392374 )
393375
394376 if user is not None and recipe is not None:
@@ -545,58 +527,40 @@ <h2 class="section-title" id="header-functions">Functions</h2>
545527 recipe: Optional[str] = None
546528
547529 async def update_user_dict(
548- get_user_func1: Callable[[str], Awaitable[GetUserResult]],
549- get_user_func2: Callable[[str], Awaitable[GetUserResult]],
550- recipe1: str,
551- recipe2: str,
530+ get_user_funcs: List[Callable[[str], Awaitable[GetUserResult]]],
531+ recipes: List[str],
552532 ):
553533 nonlocal user, user_id, recipe
554534
555- try:
556- recipe_user = await get_user_func1(user_id) # type: ignore
557-
558- if recipe_user is not None:
559- user = UserWithMetadata().from_dict(
560- recipe_user.__dict__, first_name="", last_name=""
561- )
562- recipe = recipe1
563- except Exception:
564- pass
565-
566- if user is None:
535+ for get_user_func, recipe_id in zip(get_user_funcs, recipes):
567536 try:
568- recipe_user = await get_user_func2 (user_id)
537+ recipe_user = await get_user_func (user_id) # type: ignore
569538
570539 if recipe_user is not None:
571540 user = UserWithMetadata().from_dict(
572541 recipe_user.__dict__, first_name="", last_name=""
573542 )
574- recipe = recipe2
543+ recipe = recipe_id
544+ break
575545 except Exception:
576546 pass
577547
578548 if recipe_id == EmailPasswordRecipe.recipe_id:
579549 await update_user_dict(
580- ep_get_user_by_id,
581- tpep_get_user_by_id,
582- "emailpassword",
583- "thirdpartyemailpassword",
550+ [ep_get_user_by_id, tpep_get_user_by_id],
551+ ["emailpassword", "thirdpartyemailpassword"],
584552 )
585553
586554 elif recipe_id == ThirdPartyRecipe.recipe_id:
587555 await update_user_dict(
588- tp_get_user_by_idx,
589- tpep_get_user_by_id,
590- "thirdparty",
591- "thirdpartyemailpassword",
556+ [tp_get_user_by_idx, tpep_get_user_by_id, tppless_get_user_by_id],
557+ ["thirdparty", "thirdpartyemailpassword", "thirdpartypasswordless"],
592558 )
593559
594560 elif recipe_id == PasswordlessRecipe.recipe_id:
595561 await update_user_dict(
596- pless_get_user_by_id,
597- tppless_get_user_by_id,
598- "passwordless",
599- "thirdpartypasswordless",
562+ [pless_get_user_by_id, tppless_get_user_by_id],
563+ ["passwordless", "thirdpartypasswordless"],
600564 )
601565
602566 if user is not None and recipe is not None:
0 commit comments