def register():
session.clear()
if request.method == "POST":
if not request.form.get("username"):
return apology("Missing Username!")
elif not request.form.get("password"):
return apology("Missing Password!")
if not request.form.get("password") == request.form.get("Confirm password"):
return apology("Password and Password Confirmation are not consistent!")
hash = pwd_context.hash("password")
result = db.execute("INSERT INTO users(username, hash) VALUES(:username, :hash)",
username=request.form.get("username"), hash=hash)
if not result:
return apology("Username exists already")
session["user_id"] = rows[0]["id"]
return render_template("register.html")
I got this name error from trying to register. Can someone help me please i have tried figuring it out and all i got was that pwd_context.encrypt has to change to pwd_context.hash and it still couldnt work...
hash = pwd_context.hash("password") result = db.execute("INSERT INTO users(username, hash) VALUES(:username, :hash)", username=request.form.get("username"), hash=hash) if not result: return apology("Username exists already")
NameError: name 'pwd_context' is not defined