Skip to content

Commit

Permalink
Merge pull request #1611 Use strings instead of binary strings in res…
Browse files Browse the repository at this point in the history
…et_url generation
  • Loading branch information
ukanga authored May 31, 2019
2 parents 7ec8535 + 5d0ff6f commit 4916771
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions onadata/libs/serializers/password_reset_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ def get_password_reset_email(user, reset_url,
result = urlparse(reset_url)
site_name = domain = result.hostname
encoded_username = urlsafe_base64_encode(
b(user.username.encode('utf-8')))
b(user.username.encode('utf-8'))).decode('utf-8')
c = {
'email': user.email,
'domain': domain,
'path': result.path,
'site_name': site_name,
'uid': urlsafe_base64_encode(force_bytes(user.pk)),
'uid': urlsafe_base64_encode(force_bytes(user.pk)).decode('utf-8'),
'username': user.username,
'encoded_username': encoded_username,
'token': token_generator.make_token(user),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from onadata.libs.serializers.password_reset_serializer import \
get_password_reset_email
from django.utils.http import urlsafe_base64_encode
from django.utils.encoding import force_bytes


class TestPasswordResetSerializer(TestBase):
Expand All @@ -15,3 +16,8 @@ def test_get_password_reset_email(self):
bytes(self.user.username.encode('utf-8'))).decode('utf-8'),
email,
"Username is included in reset email.")
self.assertIn(
'uid={}'.format(urlsafe_base64_encode(
force_bytes(self.user.pk)).decode('utf-8')),
email,
"Uid is included in email.")

0 comments on commit 4916771

Please sign in to comment.