Working through Pset9 and every time I try testing my register function I get back an image of a grumpy cat and a 403: Invalid username and/or password message.
This is my code for the register function:
@app.route("/register", methods=["GET", "POST"])
def register():
"""Register user"""
if request.method == "GET":
return render_template("register.html")
# Validate submission
if request.method == "POST":
name = request.form.get("username")
password= request.form.get("password")
confirmation = request.form.get("confirmation")
if name == None:
return apology("TODO")
if password == None:
return apology("TODO")
if password != confirmation:
return apology("TODO")
# TODO return apology if username already taken
hash = werkzeug.generate_password_hash(password, method='pbkdf2:sha256', salt_length=8)
db.execute("INSERT INTO finance (username, password, hash) VALUES(?, ?)", username, password, hash)
return redirect("/")
And this is the code I created at register.html:
{% extends "layout.html" %}
{% block title %}
Register
{% endblock %}
{% block main %}
<form action="/login" method="post">
<div class="mb-3">
<input autocomplete="off" autofocus class="form-control mx-auto w-auto" id="username" name="username" placeholder="Username" type="text">
</div>
<div class="mb-3">
<input class="form-control mx-auto w-auto" id="password" name="password" placeholder="Password" type="password">
</div>
<div class="mb-3">
<input class="form-control mx-auto w-auto" id="confirmation" name="confirmation" placeholder="Password" type="password">
</div>
<button class="btn btn-primary" type="submit">Register</button>
</form>
{% endblock %}
Can anyone see where I'm going wrong?