def login():
if flask.request.method == 'GET':
return flask.render_template("login.html", curid = 0)
email = flask.request.form['email']
print("IN /LOGIN: THIS IS THE email RESULT:", str(email))
cur.execute("""SELECT hashpswd, sid, validated from students where email = %s;""", (email,))
lst = cur.fetchall()
conn.commit()
if len(lst) != 0:
print("IN /LOGIN: THIS IS lst RESULT:", str(lst))
if not lst[0][2]:
return "You must validate your account first!"
print("IN /LOGIN: THIS IS check_password_hash RESULT:", str(check_password_hash(lst[0][0], flask.request.form['pw'])))
if check_password_hash(lst[0][0], flask.request.form['pw']):
user = User()
user.id = lst[0][1]
flask_login.login_user(user)
return flask.redirect(flask.url_for('student_games'))
return 'Bad login'
#==========================# STUDENT PROTECTED VIEW #==========================#
评论列表
文章目录