Пример #1
0
def login_check():
    form = LoginForm()
    if form.validate():
        user_to_login = mongo.get_user_obj(request.form["username"])
        if user_to_login and user_to_login.validate_login(request.form["password"]):
            login_user(user_to_login)
            return redirect(url_for("views.home"))
        else:
            flash("username or password incorrect")
            return redirect(url_for("views.login"))
    else:
        flash("username or password incorrect")
        return redirect(url_for("views.login"))
Пример #2
0
def load_user(username):
    return mongo.get_user_obj(username)
Пример #3
0
def user(username, page=1):
    user = mongo.get_user_obj(username)
    if user is None:
        flash("User %s not found" % username)
        return redirect(url_for("views.index"))
    return render_template("user.html", user=user)