diff --git a/otpauth/models.py b/otpauth/models.py index de2ad3e..6e1898e 100644 --- a/otpauth/models.py +++ b/otpauth/models.py @@ -2,6 +2,10 @@ from django.db import models from django.contrib.auth.models import AbstractUser from rest_framework import exceptions from rest_framework import authentication +import json +import logging + +logger = logging.getLogger(__name__) class OTPSeed(AbstractUser): @@ -27,17 +31,20 @@ from otpauth.serializer import TokenSerializer class OTPAuthentication(authentication.BaseAuthentication): def authenticate(self, request): + logger.debug("in authenticate {}".format(json.dumps(request.data))) serializer = TokenSerializer(data=request.data) if serializer.is_valid(): instance, token = serializer.save() else: + logger.error("serializer is invalid") raise exceptions.AuthenticationFailed() # not dealing with admin realm -> can only be auth [see serializer] if not instance.realm == "ungleich-admin": if not request.path == "/ungleichotp/verify/": + logger.debug("request.path is not /ungleichotp/verify/") raise exceptions.AuthenticationFailed() - # print("AUTH DONE: {} - {}".format(request.path, instance)) + logger.debug("AUTH DONE: {} - {}".format(request.path, instance)) return (instance, token)