Enabling OTP-Email 2FA Automatically on User Signup
Hello Community,
I'm currently struggling with the 2FA plugin. I would like to enable OTP-Email 2FA automatically when users sign up. However, using
auth.api.enable2FA
does not allow specifying a user.id. Even when using impersonation through the admin API, I have found it impossible to properly enable 2FA from the server side during user creation.
Does anyone have an idea or a workaround for ensuring that the 2FA data is generated and enabled automatically upon user creation?
Thank you in advance for your support!
Best regards,
Soheel1 Reply
I managed to work around it by creating the 2FA Entries in the DB by myself by copying the implementation from the better-auth Github. This however is not a pretty solution as it would break in case better-auth changes something on their end as I cannot access the functions needed from better-auth/crypto directly through imports. In case someone has a better idea I would love to hear it!