One more question -- when using MFA the `create_ne...
# support-questions-legacy
e
One more question -- when using MFA the
create_new_session
call will get the
user_id
from the latest recipe used in MFA flow, is that right? So how do I override the
user_id
to contain the ID from the very first recipe in my MFA flow?
For instance, I am using Passwordless OTP as first factor and EmailPassword (PhoneNumberPassword actually) as the second factor. I want my users to have the Passwordless recipe
user_id
. I can get that ID this way:
Copy code
python
passwordless_user_id = get_user_by_phone_number(old_session.get_access_token_payload().get("phoneNumber")).id
And then is it enough to pass that ID to
original_implementation_create_new_session
as
user_id
?
n
Right one way to do this is to check if a session already exists when the PhonenumberPassword sign in/up is called. If it does exist then you can get the user id from the session
You would need to override the api for this, and then you pass the existing user id as user context when calling the original function
Then in create_new_session the user id should be present in the user context, you can then override that function and use the value from user context to set a user id for the session
If you need help with specifics we can get on call and I can help
e
Totally forgot about the user-context, thanks! So I assume passing the desired user_id into the
original_implementation.create_new_session
should be fine I think I'm almost there with my implementation 🙂
n
Yep that should work
e
One more question -- global claim validator
SecondFactorCompletedClaim.validators.has_value(True)
does not fail if token does not contain the claim at all, is that right?
n
@KShivendu can answer that better
r
It will try and fetch the claim value from the second factor claim first, and then based on that, it will check if that claim is true or not.
The fetch value function on second factor claim returns false I think. So if the claim is not defined, it will first call the fetch value function, which will set it to false, and then it will check if the value is true or not - in this case, failing
e
@rp_st Thanks a lot 🙂
3 Views