Skip to content

Commit 20146f2

Browse files
committedJan 22, 2020
Fix send_token calls
1 parent a6dc006 commit 20146f2

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed
 

‎README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ PASSWORDLESS_AUTH = {
111111
5. You can now POST to either of the endpoints:
112112
113113
```bash
114-
curl -X POST -d "email=aaron@email.com" localhost:8000/auth/alias/
114+
curl -X POST -d "email=aaron@email.com" localhost:8000/auth/email/
115115
116116
// OR
117117
118-
curl -X POST -d "mobile=+15552143912" localhost:8000/auth/alias/
118+
curl -X POST -d "mobile=+15552143912" localhost:8000/auth/mobile/
119119
```
120120
A 6 digit callback token will be sent to the contact point.
121121
@@ -202,11 +202,11 @@ This is off by default but can be turned on with
202202
enabled they look for the User model fields ``email_verified`` or
203203
``mobile_verified``.
204204
205-
You can also use ``/validate/email/`` or ``/validate/mobile/`` which will
205+
You can also use ``auth/verify/email/`` or ``/auth/verify/mobile/`` which will
206206
automatically send a token to the endpoint attached to the current
207207
``request.user``'s email or mobile if available.
208208
209-
You can then send that token to ``/callback/verify/`` which will double-check
209+
You can then send that token to ``/auth/verify/`` which will double-check
210210
that the endpoint belongs to the request.user and mark the alias as verified.
211211
212212
Registration

‎drfpasswordless/views.py

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from rest_framework.response import Response
55
from rest_framework.permissions import AllowAny, IsAuthenticated
66
from rest_framework.views import APIView
7+
from drfpasswordless.models import CallbackToken
78
from drfpasswordless.settings import api_settings
89
from drfpasswordless.serializers import (
910
EmailAuthSerializer,
@@ -37,6 +38,11 @@ def alias_type(self):
3738
# Alias Type
3839
raise NotImplementedError
3940

41+
@property
42+
def token_type(self):
43+
# Token Type
44+
raise NotImplementedError
45+
4046
def post(self, request, *args, **kwargs):
4147
if self.alias_type.upper() not in api_settings.PASSWORDLESS_AUTH_TYPES:
4248
# Only allow auth types allowed in settings.
@@ -68,6 +74,7 @@ class ObtainEmailCallbackToken(AbstractBaseObtainCallbackToken):
6874
failure_response = "Unable to email you a login code. Try again later."
6975

7076
alias_type = 'email'
77+
token_type = CallbackToken.TOKEN_TYPE_AUTH
7178

7279
email_subject = api_settings.PASSWORDLESS_EMAIL_SUBJECT
7380
email_plaintext = api_settings.PASSWORDLESS_EMAIL_PLAINTEXT_MESSAGE
@@ -84,6 +91,7 @@ class ObtainMobileCallbackToken(AbstractBaseObtainCallbackToken):
8491
failure_response = "Unable to send you a login code. Try again later."
8592

8693
alias_type = 'mobile'
94+
token_type = CallbackToken.TOKEN_TYPE_AUTH
8795

8896
mobile_message = api_settings.PASSWORDLESS_MOBILE_MESSAGE
8997
message_payload = {'mobile_message': mobile_message}
@@ -96,6 +104,7 @@ class ObtainEmailVerificationCallbackToken(AbstractBaseObtainCallbackToken):
96104
failure_response = "Unable to email you a verification code. Try again later."
97105

98106
alias_type = 'email'
107+
token_type = CallbackToken.TOKEN_TYPE_VERIFY
99108

100109
email_subject = api_settings.PASSWORDLESS_EMAIL_VERIFICATION_SUBJECT
101110
email_plaintext = api_settings.PASSWORDLESS_EMAIL_VERIFICATION_PLAINTEXT_MESSAGE
@@ -114,6 +123,7 @@ class ObtainMobileVerificationCallbackToken(AbstractBaseObtainCallbackToken):
114123
failure_response = "Unable to send you a verification code. Try again later."
115124

116125
alias_type = 'mobile'
126+
token_type = CallbackToken.TOKEN_TYPE_VERIFY
117127

118128
mobile_message = api_settings.PASSWORDLESS_MOBILE_MESSAGE
119129
message_payload = {'mobile_message': mobile_message}

0 commit comments

Comments
 (0)
Please sign in to comment.