@@ -309,58 +309,40 @@ async def get_user_for_recipe_id(
309309 recipe : Optional [str ] = None
310310
311311 async def update_user_dict (
312- get_user_func1 : Callable [[str ], Awaitable [GetUserResult ]],
313- get_user_func2 : Callable [[str ], Awaitable [GetUserResult ]],
314- recipe1 : str ,
315- recipe2 : str ,
312+ get_user_funcs : List [Callable [[str ], Awaitable [GetUserResult ]]],
313+ recipes : List [str ],
316314 ):
317315 nonlocal user , user_id , recipe
318316
319- try :
320- recipe_user = await get_user_func1 (user_id ) # type: ignore
321-
322- if recipe_user is not None :
323- user = UserWithMetadata ().from_dict (
324- recipe_user .__dict__ , first_name = "" , last_name = ""
325- )
326- recipe = recipe1
327- except Exception :
328- pass
329-
330- if user is None :
317+ for get_user_func , recipe_id in zip (get_user_funcs , recipes ):
331318 try :
332- recipe_user = await get_user_func2 (user_id )
319+ recipe_user = await get_user_func (user_id ) # type: ignore
333320
334321 if recipe_user is not None :
335322 user = UserWithMetadata ().from_dict (
336323 recipe_user .__dict__ , first_name = "" , last_name = ""
337324 )
338- recipe = recipe2
325+ recipe = recipe_id
326+ break
339327 except Exception :
340328 pass
341329
342330 if recipe_id == EmailPasswordRecipe .recipe_id :
343331 await update_user_dict (
344- ep_get_user_by_id ,
345- tpep_get_user_by_id ,
346- "emailpassword" ,
347- "thirdpartyemailpassword" ,
332+ [ep_get_user_by_id , tpep_get_user_by_id ],
333+ ["emailpassword" , "thirdpartyemailpassword" ],
348334 )
349335
350336 elif recipe_id == ThirdPartyRecipe .recipe_id :
351337 await update_user_dict (
352- tp_get_user_by_idx ,
353- tpep_get_user_by_id ,
354- "thirdparty" ,
355- "thirdpartyemailpassword" ,
338+ [tp_get_user_by_idx , tpep_get_user_by_id , tppless_get_user_by_id ],
339+ ["thirdparty" , "thirdpartyemailpassword" , "thirdpartypasswordless" ],
356340 )
357341
358342 elif recipe_id == PasswordlessRecipe .recipe_id :
359343 await update_user_dict (
360- pless_get_user_by_id ,
361- tppless_get_user_by_id ,
362- "passwordless" ,
363- "thirdpartypasswordless" ,
344+ [pless_get_user_by_id , tppless_get_user_by_id ],
345+ ["passwordless" , "thirdpartypasswordless" ],
364346 )
365347
366348 if user is not None and recipe is not None :
0 commit comments