def login(): form = LoginForm() if request.method == 'POST': if form.validate() == False: flash('Please enter a valid password.') return render_template('login.html', form=form) if pw_check.validate(form.password.data): return render_template('login.html', success=True) else: flash('Invalid password!') return render_template('login.html', form=form) elif request.method == 'GET': return render_template('login.html', form=form)
def is_correct(form, field): if not pw_check.validate(field.data): raise ValidationError('Wrong password!')