From 1cc6bddb58072567ba969f1392ceba83de5b0e03 Mon Sep 17 00:00:00 2001 From: Jesse Fornear Date: Wed, 29 Nov 2023 15:19:25 -0600 Subject: [PATCH] Add support for using token in email subject line --- drfpasswordless/settings.py | 2 +- drfpasswordless/utils.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drfpasswordless/settings.py b/drfpasswordless/settings.py index 5b93197..ca8d78c 100644 --- a/drfpasswordless/settings.py +++ b/drfpasswordless/settings.py @@ -37,7 +37,7 @@ 'PASSWORDLESS_EMAIL_NOREPLY_ADDRESS': None, # The email subject - 'PASSWORDLESS_EMAIL_SUBJECT': "Your Login Token", + 'PASSWORDLESS_EMAIL_SUBJECT': "Your temporary login token is %s", # A plaintext email message overridden by the html message. Takes one string. 'PASSWORDLESS_EMAIL_PLAINTEXT_MESSAGE': "Enter this token to sign in: %s", diff --git a/drfpasswordless/utils.py b/drfpasswordless/utils.py index ba02deb..0d475a5 100644 --- a/drfpasswordless/utils.py +++ b/drfpasswordless/utils.py @@ -51,7 +51,7 @@ def create_callback_token_for_user(user, alias_type, token_type): to_alias=getattr(user, to_alias_field), type=token_type ) - + token = CallbackToken.objects.create(user=user, to_alias_type=alias_type_u, to_alias=getattr(user, to_alias_field), @@ -137,7 +137,7 @@ def send_email_with_callback_token(user, email_token, **kwargs): context = inject_template_context({'callback_token': email_token.key, }) html_message = loader.render_to_string(email_html, context,) send_mail( - email_subject, + email_subject % email_token.key, email_plaintext % email_token.key, api_settings.PASSWORDLESS_EMAIL_NOREPLY_ADDRESS, [getattr(user, api_settings.PASSWORDLESS_USER_EMAIL_FIELD_NAME)], @@ -169,9 +169,9 @@ def send_sms_with_callback_token(user, mobile_token, **kwargs): # even if you have suppression on– you must provide a number if you have mobile selected. if api_settings.PASSWORDLESS_MOBILE_NOREPLY_NUMBER is None: return False - + return True - + base_string = kwargs.get('mobile_message', api_settings.PASSWORDLESS_MOBILE_MESSAGE) try: