-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathutils.py
34 lines (30 loc) · 1.13 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from django.core.mail import send_mail
from django.template.loader import render_to_string
from django.utils.html import strip_tags
from django.utils.http import urlsafe_base64_encode as b64_encode
from .tokens import discord_token_generator
def send_verify_mail(email, discord_tag, host="csua.berkeley.edu"):
print("Email:", email)
print("Tag:", discord_tag)
emailb64 = b64_encode(email.encode("utf8"))
discord_tagb64 = b64_encode(discord_tag.encode("utf8"))
token = discord_token_generator.make_token((email, discord_tag))
html_message = render_to_string(
"discord_register_email.html",
{
"host": host,
"token": token,
"email": email,
"discord_tag": discord_tag,
"emailb64": emailb64,
"discord_tagb64": discord_tagb64,
},
)
send_mail(
subject="CSUA Discord Email Verification",
message=strip_tags(html_message),
recipient_list=[email],
html_message=html_message,
)