mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-12-27 05:25:40 +00:00
Ensure correct encoding when hashing and verifying
Depending on the database backend the string might not be UTF-8 encoded. This makes sure that the hashing function works regardless of that. Signed-off-by: Felix Kaechele <felix@kaechele.ca>
This commit is contained in:
parent
1712f26470
commit
d7a218a212
@ -118,11 +118,11 @@ class User(db.Model):
|
||||
# Hash a password for the first time
|
||||
# (Using bcrypt, the salt is saved into the hash itself)
|
||||
pw = plain_text_password if plain_text_password else self.plain_text_password
|
||||
return bcrypt.hashpw(pw, bcrypt.gensalt())
|
||||
return bcrypt.hashpw(pw.encode('utf-8'), bcrypt.gensalt())
|
||||
|
||||
def check_password(self, hashed_password):
|
||||
# Check hased password. Useing bcrypt, the salt is saved into the hash itself
|
||||
return bcrypt.checkpw(self.plain_text_password, hashed_password)
|
||||
return bcrypt.checkpw(self.plain_text_password.encode('utf-8'), hashed_password.encode('utf-8'))
|
||||
|
||||
def get_user_info_by_id(self):
|
||||
user_info = User.query.get(int(self.id))
|
||||
|
Loading…
Reference in New Issue
Block a user