From a73fba0f1bd20b580721e5ca59f3b1dada2a29f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Thu, 30 Dec 2021 21:12:58 +0100 Subject: [PATCH] Fix broken token authentication --- shimatta_kenkyusho/api/ExpiringAuthToken.py | 2 +- shimatta_kenkyusho/api/views.py | 1 + shimatta_kenkyusho/shimatta_kenkyusho/settings.py | 2 ++ shimatta_kenkyusho/shimatta_kenkyusho/settings_production.py | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/shimatta_kenkyusho/api/ExpiringAuthToken.py b/shimatta_kenkyusho/api/ExpiringAuthToken.py index a3ef535..dfd4358 100644 --- a/shimatta_kenkyusho/api/ExpiringAuthToken.py +++ b/shimatta_kenkyusho/api/ExpiringAuthToken.py @@ -10,7 +10,7 @@ EXPIRE_HOURS = getattr(settings, 'REST_FRAMEWORK_TOKEN_EXPIRE_HOURS', 24) class ExpiringTokenAuthentication(TokenAuthentication): def authenticate_credentials(self, key): - print(key) + #print(key) try: token = Token.objects.get(key=key) except Token.DoesNotExist: diff --git a/shimatta_kenkyusho/api/views.py b/shimatta_kenkyusho/api/views.py index d98d54a..078ca6c 100644 --- a/shimatta_kenkyusho/api/views.py +++ b/shimatta_kenkyusho/api/views.py @@ -1,5 +1,6 @@ from django.shortcuts import render from django.contrib.auth.models import User, Group +from django.core.exceptions import ObjectDoesNotExist from rest_framework import viewsets, status from rest_framework import permissions from rest_framework.views import APIView diff --git a/shimatta_kenkyusho/shimatta_kenkyusho/settings.py b/shimatta_kenkyusho/shimatta_kenkyusho/settings.py index 4ea2bcd..a585807 100644 --- a/shimatta_kenkyusho/shimatta_kenkyusho/settings.py +++ b/shimatta_kenkyusho/shimatta_kenkyusho/settings.py @@ -39,6 +39,8 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'parts.apps.PartsConfig', + 'api.apps.ApiConfig', + 'rest_framework.authtoken', 'qr_code', 'rest_framework', 'crispy_forms', diff --git a/shimatta_kenkyusho/shimatta_kenkyusho/settings_production.py b/shimatta_kenkyusho/shimatta_kenkyusho/settings_production.py index bef5c94..177ee0a 100644 --- a/shimatta_kenkyusho/shimatta_kenkyusho/settings_production.py +++ b/shimatta_kenkyusho/shimatta_kenkyusho/settings_production.py @@ -56,6 +56,8 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'parts.apps.PartsConfig', + 'api.apps.ApiConfig', + 'rest_framework.authtoken', 'qr_code', 'rest_framework', 'crispy_forms',