Opened 14 months ago
Last modified 14 months ago
#34891 closed Bug
force_str(urlsafe_base64_decode(uidb64)) returns object not value — at Initial Version
Reported by: | Jeff Lovern | Owned by: | nobody |
---|---|---|---|
Component: | Utilities | Version: | 4.2 |
Severity: | Normal | Keywords: | django.utils.encoding |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Trying to decode:
PHByb3BlcnR5IG9iamVjdCBhdCAweDAwMDAwMjU1M0ZBNTlEQTA-
bvlp6u-9b15d1fd6d30b90e81623812e9bc8d74
force_str(urlsafe_base64_decode(uidb64)) returns:
Field 'id' expected a number but got b'<property object at 0x000002553FA59DA0>'.
The above exception (invalid literal for int() with base 10: b'<property object at 0x000002553FA59DA0>') was the direct cause of the following exception:
Code:
def activate(request, uidb64, token):
try:
uid = force_str(urlsafe_base64_decode(uidb64))
user = CustomUser.objects.get(pk=uid)
except (TypeError, ValueError, OverflowError, CustomUser.DoesNotExist):
user = None
if user is not None and account_activation_token.check_token(user, token):
user.is_active = True
user.save()
login(request, user)
return redirect('account_activation_complete')
else:
return HttpResponseBadRequest('Activation link is invalid!')