mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 14:40:27 +00:00
Fix 1329
This commit is contained in:
parent
9a38e1758f
commit
ff671ebabe
@ -108,6 +108,7 @@ class User(db.Model):
|
||||
def check_password(self, hashed_password):
|
||||
# Check hashed password. Using bcrypt, the salt is saved into the hash itself
|
||||
if hasattr(self, "plain_text_password"):
|
||||
if self.plain_text_password != None:
|
||||
return bcrypt.checkpw(self.plain_text_password.encode('utf-8'),
|
||||
hashed_password.encode('utf-8'))
|
||||
return False
|
||||
@ -422,8 +423,12 @@ class User(db.Model):
|
||||
self.role_id = Role.query.filter_by(
|
||||
name='Administrator').first().id
|
||||
|
||||
if hasattr(self, "plain_text_password"):
|
||||
if self.plain_text_password != None:
|
||||
self.password = self.get_hashed_password(
|
||||
self.plain_text_password) if hasattr(self, "plain_text_password") else '*'
|
||||
self.plain_text_password)
|
||||
else:
|
||||
self.password = '*'
|
||||
|
||||
if self.password and self.password != '*':
|
||||
self.password = self.password.decode("utf-8")
|
||||
@ -460,6 +465,7 @@ class User(db.Model):
|
||||
|
||||
# store new password hash (only if changed)
|
||||
if hasattr(self, "plain_text_password"):
|
||||
if self.plain_text_password != None:
|
||||
user.password = self.get_hashed_password(
|
||||
self.plain_text_password).decode("utf-8")
|
||||
|
||||
@ -476,9 +482,11 @@ class User(db.Model):
|
||||
|
||||
user.firstname = self.firstname if self.firstname else user.firstname
|
||||
user.lastname = self.lastname if self.lastname else user.lastname
|
||||
|
||||
if hasattr(self, "plain_text_password"):
|
||||
if self.plain_text_password != None:
|
||||
user.password = self.get_hashed_password(
|
||||
self.plain_text_password).decode(
|
||||
"utf-8") if hasattr(self, "plain_text_password") else user.password
|
||||
self.plain_text_password).decode("utf-8")
|
||||
|
||||
if self.email:
|
||||
# Can not update to a new email that
|
||||
|
Loading…
Reference in New Issue
Block a user