@@ -160,7 +160,7 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
160
160
async def get_available_secondary_factor_ids(
161
161
_: TenantConfig,
162
162
) -> List[str]:
163
- return ["emailpassword" ]
163
+ return [FactorIds.WEBAUTHN ]
164
164
165
165
mfa_instance.add_func_to_get_all_available_secondary_factor_ids_from_other_recipes(
166
166
GetAllAvailableSecondaryFactorIdsFromOtherRecipesFunc(
@@ -171,11 +171,11 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
171
171
async def user_setup(user: User, _: Dict[str, Any]) -> List[str]:
172
172
for login_method in user.login_methods:
173
173
# 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
175
175
# we assume the factor is setup for this user. And as part of factor
176
176
# completion, we associate that loginMethod with the session's tenantId
177
177
if login_method.recipe_id == self.recipe_id:
178
- return ["emailpassword" ]
178
+ return [FactorIds.WEBAUTHN ]
179
179
180
180
return []
181
181
@@ -202,7 +202,8 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
202
202
203
203
# We order the login methods based on `time_joined` (oldest first)
204
204
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,
206
207
)
207
208
# We take the ones that belong to this recipe
208
209
recipe_ordered_login_methods = list(
@@ -213,7 +214,7 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
213
214
)
214
215
215
216
result: List[str] = []
216
- if len(recipe_ordered_login_methods) = = 0:
217
+ if len(recipe_ordered_login_methods) ! = 0:
217
218
# If there are login methods belonging to this recipe, the factor is set up
218
219
# In this case we only list email addresses that have a password associated with them
219
220
@@ -262,14 +263,14 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
262
263
# If there is at least one real email address linked to the user, we only suggest real addresses
263
264
result = [
264
265
lm.email
265
- for lm in recipe_ordered_login_methods
266
+ for lm in ordered_login_methods
266
267
if lm.email is not None and not is_fake_email(lm.email)
267
268
]
268
269
else:
269
270
# Else we use the fake ones
270
271
result = [
271
272
lm.email
272
- for lm in recipe_ordered_login_methods
273
+ for lm in ordered_login_methods
273
274
if lm.email is not None and is_fake_email(lm.email)
274
275
]
275
276
@@ -292,17 +293,8 @@ <h1 class="title">Module <code>supertokens_python.recipe.webauthn.recipe</code><
292
293
if email != session_login_method.email
293
294
]
294
295
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
-
304
296
return GetEmailsForFactorOkResult(
305
- factor_id_to_emails_map={"emailpassword" : result}
297
+ factor_id_to_emails_map={FactorIds.WEBAUTHN : result}
306
298
)
307
299
308
300
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>
559
551
async def get_available_secondary_factor_ids(
560
552
_: TenantConfig,
561
553
) -> List[str]:
562
- return ["emailpassword" ]
554
+ return [FactorIds.WEBAUTHN ]
563
555
564
556
mfa_instance.add_func_to_get_all_available_secondary_factor_ids_from_other_recipes(
565
557
GetAllAvailableSecondaryFactorIdsFromOtherRecipesFunc(
@@ -570,11 +562,11 @@ <h2 class="section-title" id="header-classes">Classes</h2>
570
562
async def user_setup(user: User, _: Dict[str, Any]) -> List[str]:
571
563
for login_method in user.login_methods:
572
564
# 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
574
566
# we assume the factor is setup for this user. And as part of factor
575
567
# completion, we associate that loginMethod with the session's tenantId
576
568
if login_method.recipe_id == self.recipe_id:
577
- return ["emailpassword" ]
569
+ return [FactorIds.WEBAUTHN ]
578
570
579
571
return []
580
572
@@ -601,7 +593,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
601
593
602
594
# We order the login methods based on `time_joined` (oldest first)
603
595
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,
605
598
)
606
599
# We take the ones that belong to this recipe
607
600
recipe_ordered_login_methods = list(
@@ -612,7 +605,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
612
605
)
613
606
614
607
result: List[str] = []
615
- if len(recipe_ordered_login_methods) = = 0:
608
+ if len(recipe_ordered_login_methods) ! = 0:
616
609
# If there are login methods belonging to this recipe, the factor is set up
617
610
# In this case we only list email addresses that have a password associated with them
618
611
@@ -661,14 +654,14 @@ <h2 class="section-title" id="header-classes">Classes</h2>
661
654
# If there is at least one real email address linked to the user, we only suggest real addresses
662
655
result = [
663
656
lm.email
664
- for lm in recipe_ordered_login_methods
657
+ for lm in ordered_login_methods
665
658
if lm.email is not None and not is_fake_email(lm.email)
666
659
]
667
660
else:
668
661
# Else we use the fake ones
669
662
result = [
670
663
lm.email
671
- for lm in recipe_ordered_login_methods
664
+ for lm in ordered_login_methods
672
665
if lm.email is not None and is_fake_email(lm.email)
673
666
]
674
667
@@ -691,17 +684,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
691
684
if email != session_login_method.email
692
685
]
693
686
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
-
703
687
return GetEmailsForFactorOkResult(
704
- factor_id_to_emails_map={"emailpassword" : result}
688
+ factor_id_to_emails_map={FactorIds.WEBAUTHN : result}
705
689
)
706
690
707
691
mfa_instance.add_func_to_get_emails_for_factor_from_other_recipes(
0 commit comments