From 46bfc7fd47ba9c11b1a70a5e61784228b780cc2d Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 12 Apr 2022 16:59:13 +0200 Subject: [PATCH] fix save correctly the new password and fix save profile --- ereuse_devicehub/forms.py | 7 ++----- ereuse_devicehub/views.py | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ereuse_devicehub/forms.py b/ereuse_devicehub/forms.py index 9789a06e..c5ede0cc 100644 --- a/ereuse_devicehub/forms.py +++ b/ereuse_devicehub/forms.py @@ -104,7 +104,7 @@ class ProfileForm(FlaskForm): self.last_name.data = user.last_name self.email.data = user.email self.telephone.data = user.telephone - self.country.data = user.country + self.country.data = user.country.name def save(self, commit=True): agent = g.user.individual @@ -143,18 +143,15 @@ class PasswordForm(FlaskForm): return False if not g.user.check_password(self.password.data): - self.password.errors = ['Incorrect password'] return False if self.newpassword.data != self.renewpassword.data: - self.newpassword.errors = ['Is not the same password'] - self.renewpassword.errors = ['Is not the same password'] return False return True def save(self, commit=True): - g.user.password = generate_password_hash(self.newpassword.data) + g.user.password = self.newpassword.data db.session.add(g.user) if commit: diff --git a/ereuse_devicehub/views.py b/ereuse_devicehub/views.py index bdbea6ae..12f6d4ba 100644 --- a/ereuse_devicehub/views.py +++ b/ereuse_devicehub/views.py @@ -81,7 +81,6 @@ class UserPasswordView(View): def dispatch_request(self): form = PasswordForm() - # import pdb; pdb.set_trace() db.session.commit() if form.validate_on_submit(): form.save(commit=False)