The new user receives a verify email - but when the [verify] link gets clicked it's response is a verification failed page : Invalid Link
ralixit opened this issue · 7 comments
Hello when I signup with a new user - The new user receives a verify email - but when the [verify] link gets clicked it's response is a verification failed page : Invalid Link
This link is invalid or been used already, we cannot verify using this link.
http://127.0.0.1:8000/verification/user/verify-email/Ym9hcmRtZW1iZXJAdGllcnJhc2t5LmNvbQ==/YjN5MWRkLWEyMTJkMjY5YzE3OWI3YTgwOWEwMDI1M2E0YjA5NjUz/
This link seems to be missing the -useremail- in -path(f'user/verify-email/-useremail-/-usertoken-/'-
I'm not sure if my custom Member is the issue in regards to :email = models.EmailField(_('email address'), unique=True)
class Member(AbstractBaseUser, PermissionsMixin):
# INITIAL MEMBER BASIC INFORMATION (05) #
first_name = models.CharField(_('first name'), max_length=150, blank=True)
last_name = models.CharField(_('last name'), max_length=150, blank=True)
phone = models.CharField(_('phone'), max_length=150, blank=True)
email = models.EmailField(_('email address'), unique=True)
Had this issue. Just looks like url is processing "useremail" but view is looking for "user_email". Worked for me once I made them consistent.
Had this issue. Just looks like url is processing "useremail" but view is looking for "user_email". Worked for me once I made them consistent.
[FIXED]: Nice catch, That's a bug! but that's in resending email.
I also have this problem. Any suggestions?
I'm also having this issue, I think that I may be having this problem because of my user registration form.
class SignUpForm(UserCreationForm):
username = forms.EmailField(
widget=forms.EmailInput(
attrs={
"placeholder": "Email",
"class": "form-control"
}
))
I tried changing the make token function in the token.py file in site-packages to the following:
def make_token(self, user, expiry, **kwargs):
"""
Return a token that can be used once to do a password reset
for the given user.
Args:
user (Model): the user
expiry (datetime | int): optional forced expiry date
kwargs: extra payload for the token
Returns:
(tuple): tuple containing:
token (str): the token
expiry (datetime): the expiry datetime
"""
exp = int(expiry.timestamp()) if isinstance(expiry, datetime) else expiry
payload = {'email': user.username, 'exp': exp} #Changed email to contain the value of the username
payload.update(**kwargs)
return jwt.encode(payload, self.secret, algorithm='HS256'), datetime.fromtimestamp(exp)
Still no luck.
Views.py:
def register_user(request):
msg = None
success = False
if request.method == "POST":
form = SignUpForm(request.POST)
profile_form = UserProfileForm(request.POST,)
if form.is_valid() and profile_form.is_valid():
inactive_user = send_verification_email(request, form)
profile = profile_form.save(commit=False)
if profile.user_id is None:
profile.user_id = inactive_user.id
profile.save()
msg = 'User created - please check your email to activate your account'
success = True
# return redirect("/login/")
else:
msg = 'Form is not valid'
else:
form = SignUpForm()
profile_form = UserProfileForm()
return render(request, "accounts/register.html", {"form": form, "msg": msg, "success": success, 'profile_form':profile_form})
you only need to add inactive_user.is_active=False
after inactive_user = send_verification_email(request, form)