Exemplo n.º 1
0
def login_view():
    if request.method == 'GET':
        return render_template('login.html')
    if g.user is not None and g.user.is_authenticated():
        return redirect(url_for('home'))
    username = request.form['username']
    user = User.query.filter(User.username==username).first()
    if user is None:
        flash('No such user. Please try again')
        return render_template('login.html')
    pw_check = bcrypt.check_password_hash(user.pw_hash, request.form['password'])
    if not pw_check:
        flash('Incorrect password. Please try again')
        return render_template('login.html')
    login_user(user)
    flash("Logged in successfully")
    return redirect(url_for('home'))
Exemplo n.º 2
0
def login():
    if request.method == "GET":
        return render_template("users/login.html")
    if g.user is not None and g.user.is_authenticated:
        return redirect(url_for("authenticated.index"))
    username = request.form["username"]
    user = User.query.filter(User.username == username).first()
    if user is None:
        flash("No such user. Please try again")
        return render_template("users/login.html")
    pw_check = bcrypt.check_password_hash(user.pw_hash, request.form["password"])
    if not pw_check:
        flash("Incorrect password. Please try again")
        return render_template("users/login.html")
    login_user(user)
    flash("Logged in successfully")
    return redirect(url_for("authenticated.index"))
Exemplo n.º 3
0
def login():
    if request.method == 'GET':
        return render_template('users/login.html')
    if g.user is not None and g.user.is_authenticated():
        return redirect(url_for('authenticated.index'))
    username = request.form['username']
    user = User.query.filter(User.username == username).first()
    if user is None:
        flash('No such user. Please try again')
        return render_template('users/login.html')
    pw_check = bcrypt.check_password_hash(user.pw_hash,
                                          request.form['password'])
    if not pw_check:
        flash('Incorrect password. Please try again')
        return render_template('users/login.html')
    login_user(user)
    flash("Logged in successfully")
    return redirect(url_for('authenticated.index'))
Exemplo n.º 4
0
def login_view():
    check_result = access_check()
    if check_result == "deny":
        return render_template('accessdeny.html')
    else:    
        if request.method == 'GET':
            return render_template('login.html')
        if g.user is not None and g.user.is_authenticated():
            return redirect(url_for('home'))
        username = request.form['username']
        user = User.query.filter(User.username==username).first()
        if user is None:
            flash(u'无此用户,请重试!')
            return render_template('login.html')
        pw_check = bcrypt.check_password_hash(user.pw_hash, request.form['password'])
        if not pw_check:
            flash(u'密码错误,请重试!')
            return render_template('login.html')
        login_user(user)
        flash(u"登录成功!")
        return redirect(url_for('home'))
Exemplo n.º 5
0
def login():
    if request.method == 'GET':
        return render_template('users/login.html')

    username = request.form['username']
    user = User.query.filter(User.username==username).first()
    if g.user is not None and g.user.is_authenticated() and g.user.is_active():
        return redirect(url_for('authenticated.index'))            
    if user is None:
        flash('No such user. Please try again')
        return render_template('users/login.html')
    pw_check = bcrypt.check_password_hash(user.pw_hash, request.form['password'])
    if not pw_check:
        flash('Incorrect password. Please try again')
        return render_template('users/login.html')
    login_user(user)
    if user.active == 0:
        flash('Please confirm your account by clicking the link on your email.')
        return render_template('users/login.html')
    elif user.active == 1:
        flash('Please confirm your account by entering sms code sent to your number.')
        return redirect(url_for('users.confirm_sms'))
    flash("Logged in successfully")
    return redirect(url_for('users.confirm_sms'))