server.py 文件源码

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

项目:sfparks 作者: cvlong 项目源码 文件源码
def process_login():
    """Log in existing users and redirect to homepage."""

    email = request.form.get('email')
    password = request.form.get('password')

    # select the user from the database who has the given email (if any)
    user = User.query.filter(User.email==email).first()

    if user:
        # if user in database, check that password is correct
        if password == user.password:
            session['user'] = user.user_id
            session['waypoints'] = []

            flash("You're logged in.")
            return redirect('/')

        else:            
            flash('Your password is incorrect. Please enter your information again or register as a new user.')
            return redirect('/login')

    else:
        flash('Please register as a new user.')
        return redirect('register.html')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号