#31 API Token mail

* sends an email to the support address if a new token has been generated
This commit is contained in:
2022-01-27 11:47:27 +01:00
parent c9bccec1a5
commit 6deff28389
6 changed files with 89 additions and 19 deletions

View File

@@ -11,7 +11,7 @@ from django.core.mail import send_mail
from django.template.loader import render_to_string
from django.utils.translation import gettext_lazy as _
from konova.sub_settings.django_settings import DEFAULT_FROM_EMAIL, EMAIL_REPLY_TO
from konova.sub_settings.django_settings import DEFAULT_FROM_EMAIL, EMAIL_REPLY_TO, SUPPORT_MAIL_RECIPIENT
logger = logging.getLogger(__name__)
@@ -181,3 +181,24 @@ class Mailer:
msg
)
def send_mail_verify_api_token(self, user):
""" Send a mail if a user creates a new token
Args:
user (User): The user, having a new api token
Returns:
"""
context = {
"user": user,
"EMAIL_REPLY_TO": EMAIL_REPLY_TO,
}
msg = render_to_string("email/api/verify_token.html", context)
user_mail_address = [SUPPORT_MAIL_RECIPIENT]
self.send(
user_mail_address,
_("Request for new API token"),
msg
)