0

Check50 has been returning me the following error on login : :( logging in as registered user succceeds expected status code 200, but got 400 However all the test runs I performed allowed me to register and login properly. (see below the logs I get from some testing)

INFO:werkzeug:10.240.1.0 - - [14/Apr/2018 10:13:38] "POST /register HTTP/1.1" 302 - INFO:werkzeug:10.240.0.88 - - [14/Apr/2018 10:13:40] "GET /quote HTTP/1.1" 200 - INFO:werkzeug:10.240.0.88 - - [14/Apr/2018 10:13:40] "GET /static/styles.css HTTP/1.1" 200 - INFO:werkzeug:10.240.0.87 - - [14/Apr/2018 10:13:46] "GET /logout HTTP/1.1" 302 - INFO:werkzeug:10.240.0.222 - - [14/Apr/2018 10:13:47] "GET / HTTP/1.1" 302 - INFO:werkzeug:10.240.0.87 - - [14/Apr/2018 10:13:47] "GET /login HTTP/1.1" 200 - INFO:werkzeug:10.240.0.185 - - [14/Apr/2018 10:13:48] "GET /static/styles.css HTTP/1.1" 200 - DEBUG:cs50:SELECT * FROM users WHERE username = 'bibou2' INFO:werkzeug:10.240.0.222 - - [14/Apr/2018 10:13:55] "POST /login HTTP/1.1" 302 - INFO:werkzeug:10.240.0.222 - - [14/Apr/2018 10:13:55] "GET /quote HTTP/1.1" 200 - INFO:werkzeug:10.240.0.87 - - [14/Apr/2018 10:13:56] "GET /static/styles.css HTTP/1.1" 200 -

This prevents me from running the next steps in check50 :(

If needed here is my register code :

@app.route("/register", methods=["GET", "POST"])
def register():
"""Register user"""

if request.method == "POST":

#return  render_template("register.html")

# require username and password and its confirmation
    if request.form["username"]=="":
        return apology("Missing username",400)
    elif request.form["password"] =="" or request.form["confirmation"]=="":
        return apology("Password and/or Confirmation cannot be blank",400)
    elif request.form["password"]!= request.form["confirmation"] :
        return apology("password and its confirmation must be identical",400)

# insert the new user in the db and hash the password and check if username is available
    password = request.form["password"]
    #hash = generate_password_hash(password, method='pbkdf2:sha256', salt_length=8)
    pass_hash = generate_password_hash(password)

    result = db.execute("INSERT INTO users (username, hash) VALUES(:username, :hash)",
                        username =request.form["username"], hash = pass_hash)
    if not result:
        return apology("username already used",400)

    rows = db.execute("SELECT * FROM users WHERE username = :username",
                      username=request.form.get("username"))

    session["user_id"] = rows[0]["id"]
    return redirect("/quote")

else:
    return render_template("register.html")

I think my problem is that I changed the redirect url for login and register function to "/quote" instead of "/" (that is not working either...) but i'm still stuck ..

Thanks for the help !

0

Have you implemented index yet, or does it still return an apology? If the latter, that would be a problem for check50. In the check50 details, notice the GET request:

sending POST request to /login
checking that status code 200 is returned...
sending GET request to /
checking that status code 200 is returned...

It is directed to /, which calls index.

1
  • Thanks a lot ! For some reasons i had missed this ! This works well now ! – lele701 Apr 14 '18 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .