I am working on this application and I have set up a registration and login page.
Everything works perfectly fine, the only issue is with the password validation. I am using SHA256 and every time I try logging I get this error : ValueError: not a valid sha256_crypt hash
here is a piece of def register
def register():
if request.method=="POST":
name = request.form.get("name")
username = request.form.get("username")
password = request.form.get("password")
confirm = request.form.get("confirm")
secure_password = sha256_crypt.encrypt(str(password))
def login():
if request.method == "POST":
username = request.form.get("username")
password = request.form.get("password")
usernamedata = db.execute("SELECT username FROM users WHERE username=:username", {"username":username}).fetchone()
passwordata = db.execute("SELECT password FROM users WHERE username=:username", {"username":username}).fetchone()
if usernamedata is None:
flash("No username", "danger")
return render_template("/login.html")
else:
for passwor_data in passwordata:
if sha256_crypt.verify(password,passwor_data):
flash("You are now logged in","success")
return redirect("/index.html")