Merge pull request #454 from brice-gros/alternative/convert-python-bytes-to-string-before-charfield-assignement

fix  Domain.generate_ns_secret()  storing bytes object into Domain.nameserver_update_secret
This commit is contained in:
TW 2020-01-23 01:12:46 +01:00 committed by GitHub
commit 8c391cca88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -21,6 +21,7 @@ New Features:
Fixes:
- fixed misc. crashes
- fixed Domain.generate_ns_secret() storing bytes object into Domain.nameserver_update_secret leading to trying to insert the string representation of the bytes object, so 91 characters in a varchar(88)
Other changes:

View File

@ -141,7 +141,7 @@ class Domain(models.Model):
user_model = get_user_model()
secret = user_model.objects.make_random_password(length=bitlength // 8)
secret = secret.encode('utf-8')
self.nameserver_update_secret = secret_base64 = base64.b64encode(secret)
self.nameserver_update_secret = secret_base64 = base64.b64encode(secret).decode('utf-8')
self.save()
return secret_base64