4
4
from rest_framework .response import Response
5
5
from rest_framework .permissions import AllowAny , IsAuthenticated
6
6
from rest_framework .views import APIView
7
+ from drfpasswordless .models import CallbackToken
7
8
from drfpasswordless .settings import api_settings
8
9
from drfpasswordless .serializers import (
9
10
EmailAuthSerializer ,
@@ -37,6 +38,11 @@ def alias_type(self):
37
38
# Alias Type
38
39
raise NotImplementedError
39
40
41
+ @property
42
+ def token_type (self ):
43
+ # Token Type
44
+ raise NotImplementedError
45
+
40
46
def post (self , request , * args , ** kwargs ):
41
47
if self .alias_type .upper () not in api_settings .PASSWORDLESS_AUTH_TYPES :
42
48
# Only allow auth types allowed in settings.
@@ -68,6 +74,7 @@ class ObtainEmailCallbackToken(AbstractBaseObtainCallbackToken):
68
74
failure_response = "Unable to email you a login code. Try again later."
69
75
70
76
alias_type = 'email'
77
+ token_type = CallbackToken .TOKEN_TYPE_AUTH
71
78
72
79
email_subject = api_settings .PASSWORDLESS_EMAIL_SUBJECT
73
80
email_plaintext = api_settings .PASSWORDLESS_EMAIL_PLAINTEXT_MESSAGE
@@ -84,6 +91,7 @@ class ObtainMobileCallbackToken(AbstractBaseObtainCallbackToken):
84
91
failure_response = "Unable to send you a login code. Try again later."
85
92
86
93
alias_type = 'mobile'
94
+ token_type = CallbackToken .TOKEN_TYPE_AUTH
87
95
88
96
mobile_message = api_settings .PASSWORDLESS_MOBILE_MESSAGE
89
97
message_payload = {'mobile_message' : mobile_message }
@@ -96,6 +104,7 @@ class ObtainEmailVerificationCallbackToken(AbstractBaseObtainCallbackToken):
96
104
failure_response = "Unable to email you a verification code. Try again later."
97
105
98
106
alias_type = 'email'
107
+ token_type = CallbackToken .TOKEN_TYPE_VERIFY
99
108
100
109
email_subject = api_settings .PASSWORDLESS_EMAIL_VERIFICATION_SUBJECT
101
110
email_plaintext = api_settings .PASSWORDLESS_EMAIL_VERIFICATION_PLAINTEXT_MESSAGE
@@ -114,6 +123,7 @@ class ObtainMobileVerificationCallbackToken(AbstractBaseObtainCallbackToken):
114
123
failure_response = "Unable to send you a verification code. Try again later."
115
124
116
125
alias_type = 'mobile'
126
+ token_type = CallbackToken .TOKEN_TYPE_VERIFY
117
127
118
128
mobile_message = api_settings .PASSWORDLESS_MOBILE_MESSAGE
119
129
message_payload = {'mobile_message' : mobile_message }
0 commit comments