Exemplo n.º 1
0
def user_home():
    user = MyYogi.get_user(id=session["user_id"])
    message = "Welcome %s" % user.username
    routines = user.routines
    if routines:
        return render_template("user_home.html", message=message, routines=routines)
    else:
        return render_template("user_home.html", message=message)
Exemplo n.º 2
0
def login():
    email = request.args.get("email")
    password = request.args.get("password")
    user = MyYogi.get_user(email=email, password=password)
    if user:
        session["user_id"]=user.id
        return redirect(url_for("user_home"))
    else:
        message = "Login not on file. Please try again or sign up."
        return render_template("index.html", message=message)
Exemplo n.º 3
0
def new_user():
    email = request.args.get("email")
    password = request.args.get("password")
    username = request.args.get("username")
    user = MyYogi.get_user(email=email, password=password)
    if user:
        message = "We already have that email on file. Please try again."
        return render_template("add_user.html", message=message)
    else:
        user = MyYogi.add_user(email, password, username)
        session["user_id"]=user.id
        return redirect(url_for("user_home"))