예제 #1
0
def get_login_user(user_id, user_pw):
    user = User.query.filter_by(user_id=user_id).first()
    logger.info(">>>> Searching Result user-info in DB::(user: %s)\n" % user)

    if user is not None:
        if bcrypt.check_password_hash(user.user_pw, user_pw):
            return user
        else:
            return None
    else:
        return None
예제 #2
0
def login():
    if current_user.is_authenticated:
        return redirect(url_for('home'))
    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, remember=form.remember.data)
            next_page = request.args.get('next')
            return redirect(next_page) if next_page else redirect(
                url_for('home'))
        else:
            flash('Login Unsuccessful. Please check email and password',
                  'danger')
    return render_template('login.html', title='Login', form=form)
예제 #3
0
def check_user_password(id, req):
    pwd = req["password"]
    user = User.query.filter(User.id == id).first()
    logger.info(">>>> Select user (by user_id: %s):: %s" % (id, user))

    return bcrypt.check_password_hash(user.password, pwd)