diff --git a/ungleichotp/otpauth/models.py b/ungleichotp/otpauth/models.py index 50080e0..78e7e57 100644 --- a/ungleichotp/otpauth/models.py +++ b/ungleichotp/otpauth/models.py @@ -26,3 +26,21 @@ class OTPSeed(AbstractUser): # @classmethod # def has_usable_password(cls): # pass + + +from rest_framework import exceptions +from rest_framework import authentication +from otpauth.models import OTPSeed +from otpauth.serializer import TokenSerializer + +class OTPAuthentication(authentication.BaseAuthentication): + def authenticate(self, request): + serializer = TokenSerializer(data=request.data) + + if serializer.is_valid(): + print("trying to save... {}".format(serializer)) + user = serializer.save() + else: + raise exceptions.AuthenticationFailed() + + return (user, None) diff --git a/ungleichotp/ungleichotp/settings.py b/ungleichotp/ungleichotp/settings.py index 3044056..af24e79 100644 --- a/ungleichotp/ungleichotp/settings.py +++ b/ungleichotp/ungleichotp/settings.py @@ -102,26 +102,9 @@ AUTH_PASSWORD_VALIDATORS = [ ] -from rest_framework import exceptions -from rest_framework import authentication -from otpauth.models import OTPSeed -from otpauth.serializer import TokenSerializer - -class OTPAuthentication(authentication.BaseAuthentication): - def authenticate(self, request): - serializer = TokenSerializer(data=request.data) - - if serializer.is_valid(): - print("trying to save... {}".format(serializer)) - user = serializer.save() - else: - raise exceptions.AuthenticationFailed() - - return (user, None) - REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( - 'OTPAuthentication' + 'otpauth.models.OTPAuthentication' ) }