Beispiel #1
0
def login():
    # check user already login
    if current_user.is_authenticated:
        return redirect(url_for('admin.dashboard'))
    form = LoginForm()
    # post login form
    if form.validate_on_submit():
        data = User.query.filter_by(username=form.username.data).first()
        if data is not None and data.check_password(form.password.data):
            if User.is_disabled(data):
                return redirect(url_for('admin.login'))
            # save user's session
            login_user(data)
            return redirect(url_for('admin.dashboard'))
        # return render_template('login.html', form=form)
        flash('Kombinasi username dan password salah!', 'error')
        return redirect(url_for('admin.login'))
    return render_template('login.html', form=form)
Beispiel #2
0
def check_disabled():
    if hasattr(current_user, 'id'):
        User.is_disabled(current_user)