fix save correctly the new password and fix save profile
This commit is contained in:
parent
9d4ca5a2dc
commit
46bfc7fd47
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Reference in New Issue