From e277c21a5abdf9a1cb7c06705a46d57b71a61003 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 1 Jul 2018 21:59:45 +0200 Subject: Removed useless code. --- src/web/forms.py | 22 ---------------------- src/web/templates/recover.html | 18 ------------------ src/web/views/user.py | 33 --------------------------------- 3 files changed, 73 deletions(-) delete mode 100644 src/web/templates/recover.html (limited to 'src') diff --git a/src/web/forms.py b/src/web/forms.py index 96953240..5e53946e 100644 --- a/src/web/forms.py +++ b/src/web/forms.py @@ -218,25 +218,3 @@ class InformationMessageForm(Form): message = TextAreaField(lazy_gettext("Message"), [validators.Required(lazy_gettext("Please enter a content."))]) submit = SubmitField(lazy_gettext("Send")) - - -class RecoverPasswordForm(Form): - email = EmailField(lazy_gettext("Email"), - [validators.Length(min=6, max=35), - validators.Required( - lazy_gettext("Please enter your email address."))]) - submit = SubmitField(lazy_gettext("Recover")) - - def validate(self): - if not super(RecoverPasswordForm, self).validate(): - return False - - user = User.query.filter(User.email == self.email.data).first() - if user and user.enabled: - return True - elif user and not user.enabled: - flash(lazy_gettext('Account not confirmed.'), 'danger') - return False - else: - flash(lazy_gettext('Invalid email.'), 'danger') - return False diff --git a/src/web/templates/recover.html b/src/web/templates/recover.html deleted file mode 100644 index ada110dc..00000000 --- a/src/web/templates/recover.html +++ /dev/null @@ -1,18 +0,0 @@ -{% extends "layout.html" %} -{% block content %} -
-
-

{{ _('Recover your account') }}

- {% for message in form.email.errors %} -
{{ message }}
- {% endfor %} -
- {{ form.hidden_tag() }} -
- {{ form.email(class_="form-control", placeholder=_('Your email')) }} -
- {{ form.submit(class_="btn btn-default") }} -
-
-
-{% endblock %} diff --git a/src/web/views/user.py b/src/web/views/user.py index fdcde238..1482eaa3 100644 --- a/src/web/views/user.py +++ b/src/web/views/user.py @@ -161,36 +161,3 @@ def confirm_account(token=None): else: flash(gettext('Impossible to confirm this account.'), 'danger') return redirect(url_for('login')) - - -# @user_bp.route('/recover', methods=['GET', 'POST']) -# def recover(): -# """ -# Enables the user to recover its account when he has forgotten -# its password. -# """ -# form = RecoverPasswordForm() -# user_contr = UserController() -# -# if request.method == 'POST': -# if form.validate(): -# user = user_contr.get(email=form.email.data) -# characters = string.ascii_letters + string.digits -# password = "".join(random.choice(characters) -# for x in range(random.randint(8, 16))) -# user.set_password(password) -# user_contr.update({'id': user.id}, {'password': password}) -# -# # Send the confirmation email -# try: -# notifications.new_password_notification(user, password) -# flash(gettext('New password sent to your address.'), 'success') -# except Exception as error: -# flash(gettext('Problem while sending your new password: ' -# '%(error)s', error=error), 'danger') -# -# return redirect(url_for('login')) -# return render_template('recover.html', form=form) -# -# if request.method == 'GET': -# return render_template('recover.html', form=form) -- cgit