Skip to content

Commit

Permalink
email
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxIsJoe committed Jan 21, 2024
1 parent 647c29a commit ab501dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/accounts/api/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from uuid import uuid4

from central_command import settings
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.core.mail import send_mail
from knox.models import AuthToken
from knox.views import LoginView as KnoxLoginView
from rest_framework import status
Expand Down Expand Up @@ -225,4 +227,15 @@ def post(self, request):
return Response(data={"detail": "Operation Done."}, status=status.HTTP_200_OK)

serializer.save()
send_mail(
"Password Reset Request",
"A password reset request has been made for your account.\n"
+ "Please visit the following link to reset your password: "
+ settings.APP_URL
+ serializer.data["token"]
+ "\n\nIf you have not made this request, please ignore this email. The link will expire within 35 minutes.",
settings.EMAIL_FROM_ADDRESS,
[serializer.data["account"].email],
fail_silently=False,
)
return Response(data={"detail": "Operation Done."}, status=status.HTTP_200_OK)
1 change: 1 addition & 0 deletions src/central_command/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
EMAIL_ADDRESS = os.environ.get("EMAIL_HOST_USER")
EMAIL_FROM_ADDRESS = os.environ.get("EMAIL_HOST_USER")
EMAIL_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD")
EMAIL_PASSWORD_RESET = os.environ.get("WEBSITE_URL", "https://unitystation.org/reset-password/")
EMAIL_MAIL_SUBJECT = "Confirm your Unitystation account"
EMAIL_MAIL_HTML = "registration/confirmation_email.html"
EMAIL_PAGE_TEMPLATE = "confirm_template.html"
Expand Down

0 comments on commit ab501dc

Please sign in to comment.