router.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:projectrttp 作者: alexanderldavis 项目源码 文件源码
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 #==========================#
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号