aboutsummaryrefslogtreecommitdiff
path: root/users/forms.py
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-04-30 00:34:22 -0400
committerBobby <[email protected]>2023-04-30 00:34:22 -0400
commitb3439b867b81a2d7cfb363b62b203ee2e64c0613 (patch)
tree79f85dd89786d95228e82977d4e22df8ecb4cc7e /users/forms.py
parent714953207a6c01d88c826206a41423a597a2ca2c (diff)
downloadthatcomputerscientist-b3439b867b81a2d7cfb363b62b203ee2e64c0613.tar.xz
thatcomputerscientist-b3439b867b81a2d7cfb363b62b203ee2e64c0613.zip
Email Verification Update w/ Token Expiration
Diffstat (limited to 'users/forms.py')
-rw-r--r--users/forms.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/users/forms.py b/users/forms.py
index e8c455fd..d66e560d 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -3,12 +3,9 @@
from django import forms
from django.contrib.auth.models import User
from users.models import UserProfile
-from django.conf import settings
from django.template.loader import render_to_string
from django.utils.html import strip_tags
-from django.utils.encoding import force_bytes
-from django.utils.http import urlsafe_base64_encode
-from .tokens import account_activation_token
+from .accountFunctions import store_token
from .mail_send import send_email
class RegisterForm(forms.Form):
@@ -52,13 +49,15 @@ class RegisterForm(forms.Form):
user_profile = UserProfile.objects.create(user=user)
user_profile.save()
+ uid, token = store_token(token_type='verifyemail', user=user, email=user.email)
+
# Send verification email
subject = 'Verify your email address'
message = render_to_string('verification_email.html', {
'user': user.username if user.first_name is None else user.first_name,
'site_name': 'That Computer Scientist',
- 'uid': urlsafe_base64_encode(force_bytes(user.pk)),
- 'token': account_activation_token.make_token(user),
+ 'uid': uid,
+ 'token': token,
'protocol': 'https://' if request.is_secure() else 'http://',
'domain': request.get_host(),
})