fix encoding passwords

This commit is contained in:
Cayo Puigdefabregas 2024-02-23 19:18:44 +01:00
parent 38c9f74b7b
commit 7be032bdc9
1 changed files with 2 additions and 2 deletions

View File

@ -145,13 +145,13 @@ class User(AbstractBaseUser):
self.encrypted_sensitive_data = key_crypted self.encrypted_sensitive_data = key_crypted
def encrypt_data(self, data): def encrypt_data(self, data):
pw = self.decrypt_sensitive_data() pw = self.decrypt_sensitive_data().encode('utf-8')
sb = self.get_secret_box(pw) sb = self.get_secret_box(pw)
value_enc = sb.encrypt(data.encode('utf-8')) value_enc = sb.encrypt(data.encode('utf-8'))
return base64.b64encode(value_enc).decode('utf-8') return base64.b64encode(value_enc).decode('utf-8')
def decrypt_data(self, data): def decrypt_data(self, data):
pw = self.decrypt_sensitive_data() pw = self.decrypt_sensitive_data().encode('utf-8')
sb = self.get_secret_box(pw) sb = self.get_secret_box(pw)
value = base64.b64decode(data.encode('utf-8')) value = base64.b64decode(data.encode('utf-8'))
return sb.decrypt(value).decode('utf-8') return sb.decrypt(value).decode('utf-8')