Fixing authentication error in custom sign up and login

I encountered an issue while attempting to implement custom sign up and login functionality in Anvil. To create a new authentication method, I used the following code on the client side, However, the add_mfa_method function raised an error:

What I’ve tried and what’s not working:

email = 'test@test.com'
password = '123456'
totp_secret = anvil.users.mfa.generate_totp_secret(email)
anvil.users.mfa.add_mfa_method(password, totp_secret['mfa_method'], True)
error:
anvil.users.AuthenticationFailed: Incorrect password
called from anvil-services/anvil/users/mfa/__init__.py:95

I’ve always been reluctant to do anything security-related on the Client. It’s too easy for a browser user to open the browser’s debugging windows…

Is this something that can be done server-side?

No anvil.users.mfa. does not work on server side