diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-06-16 08:03:58 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-06-16 08:03:58 +0200 |
commit | c2ad766641020930478917879d39ba61908c6fa1 (patch) | |
tree | f750c421701f4568fe546cfda28dd28a6d7598b1 /pyaggr3g470r/forms.py | |
parent | Updated translations. (diff) | |
download | newspipe-c2ad766641020930478917879d39ba61908c6fa1.tar.gz newspipe-c2ad766641020930478917879d39ba61908c6fa1.tar.bz2 newspipe-c2ad766641020930478917879d39ba61908c6fa1.zip |
Enables the user to recover its account when he has forgotten its password.
Diffstat (limited to 'pyaggr3g470r/forms.py')
-rw-r--r-- | pyaggr3g470r/forms.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pyaggr3g470r/forms.py b/pyaggr3g470r/forms.py index 5e977071..e35d8b2a 100644 --- a/pyaggr3g470r/forms.py +++ b/pyaggr3g470r/forms.py @@ -116,3 +116,25 @@ class InformationMessageForm(Form): subject = TextField(lazy_gettext("Subject"), [validators.Required(lazy_gettext("Please enter a subject."))]) message = TextAreaField(lazy_gettext("Message"), [validators.Required(lazy_gettext("Please enter a content."))]) submit = SubmitField(lazy_gettext("Send")) + +class RecoverPasswordForm(Form): + email = EmailField("Email", [validators.Length(min=6, max=35), validators.Required(lazy_gettext("Please enter your email address."))]) + submit = SubmitField(lazy_gettext("Save")) + + def __init__(self, *args, **kwargs): + Form.__init__(self, *args, **kwargs) + + def validate(self): + if not Form.validate(self): + return False + + user = User.query.filter(User.email == self.email.data).first() + if user and user.activation_key == "": + return True + elif user and user.activation_key != "": + flash(lazy_gettext('Account not confirmed.'), 'danger') + return False + else: + flash(lazy_gettext('Invalid email.'), 'danger') + #self.email.errors.append("Invalid email") + return False |