Auth: set token as request.auth

This commit is contained in:
Nico Schottelius 2018-11-18 13:05:21 +01:00
parent 26789ff11b
commit 9dc6e02029
3 changed files with 4 additions and 3 deletions

View File

@ -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)

View File

@ -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)

View File

@ -104,6 +104,7 @@ AUTH_PASSWORD_VALIDATORS = [
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'otpauth.models.OTPAuthentication'
)
}