@@ -160,7 +160,7 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
160160 async def get_available_secondary_factor_ids(
161161 _: TenantConfig,
162162 ) -> List[str]:
163- return ["emailpassword" ]
163+ return [FactorIds.WEBAUTHN ]
164164
165165 mfa_instance.add_func_to_get_all_available_secondary_factor_ids_from_other_recipes(
166166 GetAllAvailableSecondaryFactorIdsFromOtherRecipesFunc(
@@ -171,11 +171,11 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
171171 async def user_setup(user: User, _: Dict[str, Any]) -> List[str]:
172172 for login_method in user.login_methods:
173173 # We don't check for tenantId here because if we find the user
174- # with emailpassword loginMethod from different tenant, then
174+ # with webauthn loginMethod from different tenant, then
175175 # we assume the factor is setup for this user. And as part of factor
176176 # completion, we associate that loginMethod with the session's tenantId
177177 if login_method.recipe_id == self.recipe_id:
178- return ["emailpassword" ]
178+ return [FactorIds.WEBAUTHN ]
179179
180180 return []
181181
@@ -202,7 +202,8 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
202202
203203 # We order the login methods based on `time_joined` (oldest first)
204204 ordered_login_methods = sorted(
205- user.login_methods, key=lambda lm: lm.time_joined, reverse=True
205+ user.login_methods,
206+ key=lambda lm: lm.time_joined,
206207 )
207208 # We take the ones that belong to this recipe
208209 recipe_ordered_login_methods = list(
@@ -213,7 +214,7 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
213214 )
214215
215216 result: List[str] = []
216- if len(recipe_ordered_login_methods) = = 0:
217+ if len(recipe_ordered_login_methods) ! = 0:
217218 # If there are login methods belonging to this recipe, the factor is set up
218219 # In this case we only list email addresses that have a password associated with them
219220
@@ -262,14 +263,14 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
262263 # If there is at least one real email address linked to the user, we only suggest real addresses
263264 result = [
264265 lm.email
265- for lm in recipe_ordered_login_methods
266+ for lm in ordered_login_methods
266267 if lm.email is not None and not is_fake_email(lm.email)
267268 ]
268269 else:
269270 # Else we use the fake ones
270271 result = [
271272 lm.email
272- for lm in recipe_ordered_login_methods
273+ for lm in ordered_login_methods
273274 if lm.email is not None and is_fake_email(lm.email)
274275 ]
275276
@@ -292,17 +293,8 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
292293 if email != session_login_method.email
293294 ]
294295
295- # If the list is empty we generate an email address to make the flow where the user is never asked for
296- # an email address easier to implement. In many cases when the user adds an email-password factor, they
297- # actually only want to add a password and do not care about the associated email address.
298- # Custom implementations can choose to ignore this, and ask the user for the email anyway.
299- if len(result) == 0:
300- result.append(
301- f"{session_recipe_user_id.get_as_string()}@stfakeemail.supertokens.com"
302- )
303-
304296 return GetEmailsForFactorOkResult(
305- factor_id_to_emails_map={"emailpassword" : result}
297+ factor_id_to_emails_map={FactorIds.WEBAUTHN : result}
306298 )
307299
308300 mfa_instance.add_func_to_get_emails_for_factor_from_other_recipes(
@@ -559,7 +551,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
559551 async def get_available_secondary_factor_ids(
560552 _: TenantConfig,
561553 ) -> List[str]:
562- return ["emailpassword" ]
554+ return [FactorIds.WEBAUTHN ]
563555
564556 mfa_instance.add_func_to_get_all_available_secondary_factor_ids_from_other_recipes(
565557 GetAllAvailableSecondaryFactorIdsFromOtherRecipesFunc(
@@ -570,11 +562,11 @@ <h2 class="section-title" id="header-classes">Classes</h2>
570562 async def user_setup(user: User, _: Dict[str, Any]) -> List[str]:
571563 for login_method in user.login_methods:
572564 # We don't check for tenantId here because if we find the user
573- # with emailpassword loginMethod from different tenant, then
565+ # with webauthn loginMethod from different tenant, then
574566 # we assume the factor is setup for this user. And as part of factor
575567 # completion, we associate that loginMethod with the session's tenantId
576568 if login_method.recipe_id == self.recipe_id:
577- return ["emailpassword" ]
569+ return [FactorIds.WEBAUTHN ]
578570
579571 return []
580572
@@ -601,7 +593,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
601593
602594 # We order the login methods based on `time_joined` (oldest first)
603595 ordered_login_methods = sorted(
604- user.login_methods, key=lambda lm: lm.time_joined, reverse=True
596+ user.login_methods,
597+ key=lambda lm: lm.time_joined,
605598 )
606599 # We take the ones that belong to this recipe
607600 recipe_ordered_login_methods = list(
@@ -612,7 +605,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
612605 )
613606
614607 result: List[str] = []
615- if len(recipe_ordered_login_methods) = = 0:
608+ if len(recipe_ordered_login_methods) ! = 0:
616609 # If there are login methods belonging to this recipe, the factor is set up
617610 # In this case we only list email addresses that have a password associated with them
618611
@@ -661,14 +654,14 @@ <h2 class="section-title" id="header-classes">Classes</h2>
661654 # If there is at least one real email address linked to the user, we only suggest real addresses
662655 result = [
663656 lm.email
664- for lm in recipe_ordered_login_methods
657+ for lm in ordered_login_methods
665658 if lm.email is not None and not is_fake_email(lm.email)
666659 ]
667660 else:
668661 # Else we use the fake ones
669662 result = [
670663 lm.email
671- for lm in recipe_ordered_login_methods
664+ for lm in ordered_login_methods
672665 if lm.email is not None and is_fake_email(lm.email)
673666 ]
674667
@@ -691,17 +684,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
691684 if email != session_login_method.email
692685 ]
693686
694- # If the list is empty we generate an email address to make the flow where the user is never asked for
695- # an email address easier to implement. In many cases when the user adds an email-password factor, they
696- # actually only want to add a password and do not care about the associated email address.
697- # Custom implementations can choose to ignore this, and ask the user for the email anyway.
698- if len(result) == 0:
699- result.append(
700- f"{session_recipe_user_id.get_as_string()}@stfakeemail.supertokens.com"
701- )
702-
703687 return GetEmailsForFactorOkResult(
704- factor_id_to_emails_map={"emailpassword" : result}
688+ factor_id_to_emails_map={FactorIds.WEBAUTHN : result}
705689 )
706690
707691 mfa_instance.add_func_to_get_emails_for_factor_from_other_recipes(
0 commit comments