Auth: set token as request.auth
This commit is contained in:
parent
26789ff11b
commit
9dc6e02029
|
@ -39,8 +39,8 @@ class OTPAuthentication(authentication.BaseAuthentication):
|
||||||
|
|
||||||
if serializer.is_valid():
|
if serializer.is_valid():
|
||||||
print("trying to save... {}".format(serializer))
|
print("trying to save... {}".format(serializer))
|
||||||
user = serializer.save()
|
user, token = serializer.save()
|
||||||
else:
|
else:
|
||||||
raise exceptions.AuthenticationFailed()
|
raise exceptions.AuthenticationFailed()
|
||||||
|
|
||||||
return (user, None)
|
return (user, token)
|
||||||
|
|
|
@ -78,4 +78,4 @@ class TokenSerializer(serializers.Serializer):
|
||||||
if not totp.verify(token_in, valid_window=3):
|
if not totp.verify(token_in, valid_window=3):
|
||||||
raise exceptions.AuthenticationFailed()
|
raise exceptions.AuthenticationFailed()
|
||||||
|
|
||||||
return db_instance
|
return (db_instance, token_in)
|
||||||
|
|
|
@ -104,6 +104,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||||
|
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||||||
|
'rest_framework.authentication.SessionAuthentication',
|
||||||
'otpauth.models.OTPAuthentication'
|
'otpauth.models.OTPAuthentication'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue