Beispiel #1
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('dashboard'))

    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user and bcrypt.check_password_hash(user.password,
                                               form.password.data):
            login_user(user)
            return redirect(url_for('dashboard'))
        else:
            flash('please check your credentials', 'danger')
    return render_template('login.html', form=form)
Beispiel #2
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('dashboard'))
    
    form = LoginForm()	
    if form.validate_on_submit():
        user=get_user_by_email(form.email.data)
        if user and bcrypt.check_password_hash(user['password'],form.password.data):
            
            login_user(User(user['username'],user['email'],user['password'],user['image_file'],user['interests']))
            return redirect(url_for('dashboard'))
        else:
            flash('please check your credentials', 'danger')
    return render_template('login.html', form =form)