Auth: set token as request.auth
This commit is contained in:
parent
26789ff11b
commit
9dc6e02029
3 changed files with 4 additions and 3 deletions
|
@ -39,8 +39,8 @@ class OTPAuthentication(authentication.BaseAuthentication):
|
|||
|
||||
if serializer.is_valid():
|
||||
print("trying to save... {}".format(serializer))
|
||||
user = serializer.save()
|
||||
user, token = serializer.save()
|
||||
else:
|
||||
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):
|
||||
raise exceptions.AuthenticationFailed()
|
||||
|
||||
return db_instance
|
||||
return (db_instance, token_in)
|
||||
|
|
|
@ -104,6 +104,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||||
'rest_framework.authentication.SessionAuthentication',
|
||||
'otpauth.models.OTPAuthentication'
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue