I implemented the register function for pset7. It went to the register page that I had implemented. I gave the required credentials and clicked Register. But instead of registering with the credentials and redirecting me to the home page, it showed a HTML page with this text:
***Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application***
I went back to the IDE and looked for any error messages. And I saw this:
*File "/home/ubuntu/workspace/pset7/finance/application.py", line 131, in register
db.execute("INSERT INTO users WHERE username = :username AND hash = :hash", username = request.form.get("username"), hash = pwd_context.encrypt(request.form.get("password")))
File "/opt/pyenv/versions/3.6.0/lib/python3.6/site-packages/passlib/utils/decor.py", line 190, in wrapper
warn(msg % tmp, DeprecationWarning, stacklevel=2)
**DeprecationWarning: the method passlib.context.CryptContext.encrypt() is deprecated as of Passlib 1.7, and will be removed in Passlib 2.0, use CryptContext.hash() instead.**
INFO:werkzeug:10.240.1.50 - - [21/May/2018 06:11:13] "POST /register HTTP/1.1" 500 -*
The part I formatted in bold is what I am worried about. It tells me to use CryptContextHash() instead of pwd_context.encrypt() as mentioned in the short. Should I use CryptContextHash? Are there any changes I have to make any changes to login doing so? Or have I made an error in my code:
***# register user
else:
# add user's data to database
db.execute("INSERT INTO users WHERE username = :username AND hash = :hash", username = request.form.get("username"), hash = pwd_context.encrypt(request.form.get("password")))
# sign user in
session["user_id"] = rows[0]["id"]
# redirect user to homepage
return redirect(url_for("index"))***