aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r/forms.py')
-rw-r--r--pyaggr3g470r/forms.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/pyaggr3g470r/forms.py b/pyaggr3g470r/forms.py
index f9bb5a7a..7439c34b 100644
--- a/pyaggr3g470r/forms.py
+++ b/pyaggr3g470r/forms.py
@@ -27,11 +27,15 @@ __copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "GPLv3"
from flask.ext.wtf import Form
+from flask import flash
from wtforms import TextField, TextAreaField, PasswordField, BooleanField, SubmitField, validators
-import models
+from pyaggr3g470r.models import User
class SigninForm(Form):
+ """
+ Sign in form.
+ """
email = TextField("Email", [validators.Required("Please enter your email address."), validators.Email("Please enter your email address.")])
password = PasswordField('Password', [validators.Required("Please enter a password.")])
submit = SubmitField("Log In")
@@ -43,11 +47,12 @@ class SigninForm(Form):
if not Form.validate(self):
return False
- user = models.User.objects(email = self.email.data).first()
+ user = User.query.filter(User.email == self.email.data).first()
if user and user.check_password(self.password.data):
return True
else:
- self.email.errors.append("Invalid e-mail or password")
+ flash('Invalid email or password', 'danger')
+ #self.email.errors.append("Invalid email or password")
return False
class AddFeedForm(Form):
bgstack15