@@ -132,7 +132,7 @@ def callback():
132
132
async def get_available_secondary_factor_ids (
133
133
_ : TenantConfig ,
134
134
) -> List [str ]:
135
- return ["emailpassword" ]
135
+ return [FactorIds . WEBAUTHN ]
136
136
137
137
mfa_instance .add_func_to_get_all_available_secondary_factor_ids_from_other_recipes (
138
138
GetAllAvailableSecondaryFactorIdsFromOtherRecipesFunc (
@@ -143,11 +143,11 @@ async def get_available_secondary_factor_ids(
143
143
async def user_setup (user : User , _ : Dict [str , Any ]) -> List [str ]:
144
144
for login_method in user .login_methods :
145
145
# We don't check for tenantId here because if we find the user
146
- # with emailpassword loginMethod from different tenant, then
146
+ # with webauthn loginMethod from different tenant, then
147
147
# we assume the factor is setup for this user. And as part of factor
148
148
# completion, we associate that loginMethod with the session's tenantId
149
149
if login_method .recipe_id == self .recipe_id :
150
- return ["emailpassword" ]
150
+ return [FactorIds . WEBAUTHN ]
151
151
152
152
return []
153
153
@@ -174,7 +174,8 @@ async def get_emails_for_factor(
174
174
175
175
# We order the login methods based on `time_joined` (oldest first)
176
176
ordered_login_methods = sorted (
177
- user .login_methods , key = lambda lm : lm .time_joined , reverse = True
177
+ user .login_methods ,
178
+ key = lambda lm : lm .time_joined ,
178
179
)
179
180
# We take the ones that belong to this recipe
180
181
recipe_ordered_login_methods = list (
@@ -185,7 +186,7 @@ async def get_emails_for_factor(
185
186
)
186
187
187
188
result : List [str ] = []
188
- if len (recipe_ordered_login_methods ) = = 0 :
189
+ if len (recipe_ordered_login_methods ) ! = 0 :
189
190
# If there are login methods belonging to this recipe, the factor is set up
190
191
# In this case we only list email addresses that have a password associated with them
191
192
@@ -234,14 +235,14 @@ async def get_emails_for_factor(
234
235
# If there is at least one real email address linked to the user, we only suggest real addresses
235
236
result = [
236
237
lm .email
237
- for lm in recipe_ordered_login_methods
238
+ for lm in ordered_login_methods
238
239
if lm .email is not None and not is_fake_email (lm .email )
239
240
]
240
241
else :
241
242
# Else we use the fake ones
242
243
result = [
243
244
lm .email
244
- for lm in recipe_ordered_login_methods
245
+ for lm in ordered_login_methods
245
246
if lm .email is not None and is_fake_email (lm .email )
246
247
]
247
248
@@ -264,17 +265,8 @@ async def get_emails_for_factor(
264
265
if email != session_login_method .email
265
266
]
266
267
267
- # If the list is empty we generate an email address to make the flow where the user is never asked for
268
- # an email address easier to implement. In many cases when the user adds an email-password factor, they
269
- # actually only want to add a password and do not care about the associated email address.
270
- # Custom implementations can choose to ignore this, and ask the user for the email anyway.
271
- if len (result ) == 0 :
272
- result .append (
273
- f"{ session_recipe_user_id .get_as_string ()} @stfakeemail.supertokens.com"
274
- )
275
-
276
268
return GetEmailsForFactorOkResult (
277
- factor_id_to_emails_map = {"emailpassword" : result }
269
+ factor_id_to_emails_map = {FactorIds . WEBAUTHN : result }
278
270
)
279
271
280
272
mfa_instance .add_func_to_get_emails_for_factor_from_other_recipes (
0 commit comments