コード例 #1
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.get(form.email.data)
        if user is not None and check_password_hash(user.password, form.password.data):
            login_user(user, form.remember_me.data)
            next = request.args.get('next')
            if next is None or not next.startswith('/'):
                next = url_for('index')
            identity_changed.send(current_app._get_current_object(), identity=Identity(user.id))
            flash('Uspješno ste se prijavili!', category='success')
            return redirect(next)
        flash('Neispravno korisničko ime ili zaporka!', category='warning')
    return render_template('login.html', form=form)
コード例 #2
0
def admin_login():
    if request.method == "POST":
        user = User.get(request.form["username"])
        if user is not None:
            pass_hash = hash_pass(request.form["password"])
            if user.password == pass_hash:
                login_user(user)

                flash("Logged in successfully.")
                nexturl = request.args.get("next")
                if not utils.is_safe_url(nexturl):
                    return abort(400)
                return redirect(nexturl or url_for("admin_index"))
        return render_template(
            "admin/login.html",
            message="Error: Incorrect username and/or password.",
            message_style="error")
    return render_template("admin/login.html")
コード例 #3
0
ファイル: app.py プロジェクト: emin100/barmanapi
def get_password(username):
    user = User().get_user(username)
    user['username'] = username
    g.user = user.copy()
    g.user['password'] = ''
    return user.get('password')
コード例 #4
0
def load_user(user_id):
    return User.get(user_id)
コード例 #5
0
ファイル: app.py プロジェクト: tom2jack/barmanapi
def get_password(username):
    user = User().get_user(username)
    user['username'] = username
    g.user = user.copy()
    g.user['password'] = ''
    return user.get('password')