Skip to content

Commit c6d2ccb

Browse files
committedJun 17, 2020
configurable email
1 parent c63bd59 commit c6d2ccb

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed
 

‎README.md

+9
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,15 @@ DEFAULTS = {
309309
# exchanging a passwordless token for a real user auth token.
310310
'PASSWORDLESS_AUTH_TOKEN_SERIALIZER': 'drfpasswordless.serializers.TokenResponseSerializer'
311311
312+
# A dictionary of demo user's primary key mapped to their static pin
313+
'PASSWORDLESS_DEMO_USERS': {},
314+
315+
# configurable function for sending email
316+
'PASSWORDLESS_EMAIL_CALLBACK': 'drfpasswordless.utils.send_email_with_callback_token'
317+
# configurable function for sending sms
318+
'PASSWORDLESS_SMS_CALLBACK': 'drfpasswordless.utils.send_sms_with_callback_token'
319+
320+
312321
}
313322
```
314323

‎drfpasswordless/services.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
from django.utils.module_loading import import_string
12
from drfpasswordless.settings import api_settings
23
from drfpasswordless.utils import (
34
create_callback_token_for_user,
4-
send_email_with_callback_token,
5-
send_sms_with_callback_token
65
)
76

87

@@ -15,9 +14,9 @@ def send_token(user, alias_type, token_type, **message_payload):
1514
if user.pk in api_settings.PASSWORDLESS_DEMO_USERS.keys():
1615
return True
1716
if alias_type == 'email':
18-
send_action = send_email_with_callback_token
17+
send_action = import_string(api_settings.PASSWORDLESS_EMAIL_CALLBACK)
1918
elif alias_type == 'mobile':
20-
send_action = send_sms_with_callback_token
19+
send_action = import_string(api_settings.PASSWORDLESS_SMS_CALLBACK)
2120
# Send to alias
2221
success = send_action(user, token, **message_payload)
2322
return success

‎drfpasswordless/settings.py

+3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@
8585

8686
# A dictionary of demo user's primary key mapped to their static pin
8787
'PASSWORDLESS_DEMO_USERS': {},
88+
'PASSWORDLESS_EMAIL_CALLBACK': 'drfpasswordless.utils.send_email_with_callback_token',
89+
'PASSWORDLESS_SMS_CALLBACK': 'drfpasswordless.utils.send_sms_with_callback_token',
90+
8891
}
8992

9093
# List of settings that may be in string import notation.

0 commit comments

Comments
 (0)
Please sign in to comment.