Exemplo n.º 1
0
def post_login(form: SigninForm):
    if not form.validate_on_submit():
        flash_error(form.errors)
        return render_template('home/login.html', form=form)

    check_user = ProviderUser.objects(email=form.email.data).first()
    if not check_user:
        flash_error(gettext(u'User not found.'))
        return render_template('home/login.html', form=form)

    if check_user.status == ProviderUser.Status.NO_ACTIVE:
        flash_error(gettext(u'User not active.'))
        return render_template('home/login.html', form=form)

    if not ProviderUser.check_password_hash(check_user['password'],
                                            form.password.data):
        flash_error(gettext(u'Invalid password.'))
        return render_template('home/login.html', form=form)

    login_user_wrap(check_user)
    return redirect(url_for('ProviderView:dashboard'))
Exemplo n.º 2
0
def post_login(form: SignInForm):
    if not form.validate_on_submit():
        flash_error(form.errors)
        return render_template('home/login.html', form=form)

    email = form.email.data.lower()
    check_user = ProviderUser.get_by_email(email)
    if not check_user:
        flash_error('User not found.')
        return render_template('home/login.html', form=form)

    if check_user.status == ProviderUser.Status.NO_ACTIVE:
        flash_error('User not active.')
        return render_template('home/login.html', form=form)

    if not ProviderUser.check_password_hash(check_user.password, form.password.data):
        flash_error('Invalid password.')
        return render_template('home/login.html', form=form)

    check_user.login()
    return redirect(url_for('ProviderView:dashboard'))