Skip to content

Commit

Permalink
Merge pull request #31 from tomaspalma/feature/send-email
Browse files Browse the repository at this point in the history
setup mailtrap email sending for demo purposes
  • Loading branch information
tomaspalma committed Jun 5, 2024
2 parents 2ea78ac + 3b8eb63 commit 6d3e631
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions django/tts_be/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,8 @@
CORS_ALLOW_CREDENTIALS = True

VERIFY_EXCHANGE_TOKEN_EXPIRATION_SECONDS = 3600 * 24

EMAIL_HOST = ''
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = ''
7 changes: 7 additions & 0 deletions django/university/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.core.mail import send_mail
from datetime import datetime, timedelta
from django.utils import timezone
from django.http.response import HttpResponse
Expand Down Expand Up @@ -371,6 +372,12 @@ def submit_direct_exchange(request):
if not(participant in tokens_to_generate):
token = jwt.encode({"username": participant, "exchange_id": exchange_model.id, "exp": (datetime.datetime.now() + datetime.timedelta(seconds=VERIFY_EXCHANGE_TOKEN_EXPIRATION_SECONDS)).timestamp()}, JWT_KEY, algorithm="HS256")
tokens_to_generate[participant] = token
send_mail(
'Confirmação de troca',
f'https://localhost:3100/tts/verify_direct_exchange/{token}',
'[email protected]',
[f'up{participant}@up.pt'],
fail_silently=False)
inserted_exchange.save()

# 2. Send confirmation email
Expand Down

0 comments on commit 6d3e631

Please sign in to comment.