I’m attempting to implement the custom login flow and have sign in and password reset working, but I cannot add new users via the sign up button. I receive the following error after entering the relevant form information and clicking Sign Up. Any ideas? Thanks!
TypeError: Unicode-objects must be encoded before hashing
at /usr/local/lib/python3.6/site-packages/bcrypt/init.py, line 61
called from custom_signup.ServerModule1.py, line 59
called from anvil-dep-apps/custom_signup/login_flow.py, line 66 column 10
called from LoginPage, line 34
Looks like you’re using Python 3, whereas our sample code was for Python 2! This fix is simple - you need to call .encode() on the password string before passing it into bcrypt. Line 59 of ServerModule1:
Update: Flipping from Python 3 to 2.7 in both my app and the sign up dependency resolves this error. But it would be nice to be able to use Python 3 for development while using the provided login flow.
A belated thank you for the tip.
Unfortunately, I’m now receiving a different error on signup, as follows (login still works OK):
anvil.server.SerializationError: Cannot serialize arguments to function. Cannot serialize <class ‘bytes’>
objects.
at /downlink/anvil/_threaded_server.py, line 281
called from /downlink/anvil/_server.py, line 37
called from custom_signup.ServerModule1.py, line 69
called from /downlink/tables/init.py, line 63
called from custom_signup.ServerModule1.py, line 72
called from anvil-dep-apps/custom_signup/login_flow.py, line 66 column 10
called from LoginPage, line 34
I haven’t made any changes to the custom sign up dependency except for the one you prescribed. The servermodule in the custom signup flow is set to Python 2 restricted while I am using 3 in my app. Don’t know if these are relevant. Thanks in advance!
Now I had same problem in Python 10 Beta)
I just switched to Python 10 Beta to add some packages but Custom sigh up form stopped to work and I installed bcrypt package and Custom sigh up form working again)