studygyaan / tutorials

32 stars 23 forks source link

Activation link is invalid! #1

Open jslovern391 opened 1 year ago

jslovern391 commented 1 year ago

First I want to say thanks so much for this documentation. I have been looking for something like this for a CustomUser.

First thing the email shows the HTML.

Hello ,

Please click the link below to activate your account:

Activate your account">

If you did not register on our site, please ignore this message.

Best regards, Your Website Team

Second thing is that the link is invalid and trying to figure out where the issue is.

Thanks much.

jslovern391 commented 1 year ago

I added a log to this function and it returns nothing.

def activate(request, uidb64, token): try: uid = force_str(urlsafe_base64_decode(uidb64)) user = CustomUser.objects.get(pk=uid) file = open('D:\OneDrive\Rock Tech\path.txt', 'a') file.write(uidb64) file.write(token) file.close() 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!')
jslovern391 commented 1 year ago

http://127.0.0.1:8000/accounts/activate/PHByb3BlcnR5IG9iamVjdCBhdCAweDAwMDAwMkQ2NDIyRjlEQTA-/bvli4g-8c111a7a6a56ded32a3f3d7b0495ad44/

http://127.0.0.1:8000/accounts/activate/PHByb3BlcnR5IG9iamVjdCBhdCAweDAwMDAwMUJFMzc3NDlEQTA-/bvlhwj-699b4b186965d946c5d2f707d4a94512/

The first part of the token is the same and the second part is not coming through.

jslovern391 commented 1 year ago

So the uid is giving a property not a value

<property object at 0x000001D3123D9DA0>