示例#1
0
def dangnhap():
    if request.method == "GET":
        return render_template("dangnhap.html")
    elif request.method == "POST":
        user = User.objects(username=request.form["username"]).first()
        if user and user.password == request.form["password"]:
            session_user = SessionUser(user.id)
            user.update(set__token=str(user.id))
            login_user(session_user)
            return redirect(url_for("addfood"))
        else:
            return render_template("dangnhap.html")
示例#2
0
def login1():
    if request.method == "GET":
        return render_template("login1.html")
    elif request.method == "POST":
        user = User.objects(username=request.form['username']).first()
        if user and user.password == request.form['password']:
            session_user = SessionUser(user.id)
            user.update(set__token=str(user.id))
            login_user(session_user)

            return redirect(url_for('add_food'))
        else:
            return render_template("login1.html")
示例#3
0
文件: app.py 项目: dragon15098/txgd
def login_web():
    if request.method == "GET":
        return render_template("login.html")
    elif request.method == "POST":
        user = User.objects(username=request.form["username"]).first()
        if user and user.password == request.form["password"]:
            session_user = SessionUser(user.id)
            user.update(set__token=str(user.id))
            login_user(session_user)
            return render_template("homepage_login.html")
        else:
            pass
            return redirect(url_for("login_web"))
示例#4
0
def user_loader(user_token):
    found_user = User.objects(token=user_token).first()
    if found_user:
        session_user = SessionUser(found_user.id)
        return session_user