Compare commits

..

No commits in common. "665fbf852aab412ff14b0f3a72bfa162b5284510" and "b8ab991a4f3287b0e9b2e2a2567e063d1444501e" have entirely different histories.

2 changed files with 10 additions and 14 deletions

View File

@ -29,14 +29,14 @@ def NewSnapshot(request):
return JsonResponse({'error': 'Invalid request method'}, status=400)
# Authentication
auth_header = request.headers.get('Authorization')
if not auth_header or not auth_header.startswith('Bearer '):
return JsonResponse({'error': 'Invalid or missing token'}, status=401)
# auth_header = request.headers.get('Authorization')
# if not auth_header or not auth_header.startswith('Bearer '):
# return JsonResponse({'error': 'Invalid or missing token'}, status=401)
token = auth_header.split(' ')[1]
tk = Token.objects.filter(token=token).first()
if not tk:
return JsonResponse({'error': 'Invalid or missing token'}, status=401)
# token = auth_header.split(' ')[1]
# tk = Token.objects.filter(token=token).first()
# if not tk:
# return JsonResponse({'error': 'Invalid or missing token'}, status=401)
# Validation snapshot
try:
@ -60,7 +60,9 @@ def NewSnapshot(request):
# save_in_disk(data, tk.user)
try:
Build(data, tk.user)
# Build(data, tk.user)
user = User.objects.get(email="user@example.org")
Build(data, user)
except Exception:
return JsonResponse({'status': 'fail'}, status=200)

View File

@ -1,9 +1,6 @@
from uuid import uuid4
from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model
from user.models import Institution
from api.models import Token
User = get_user_model()
@ -31,6 +28,3 @@ class Command(BaseCommand):
)
self.u.set_password(self.password)
self.u.save()
token = uuid4()
Token.objects.create(token=token, owner=self.u)
print(f"TOKEN: {token}")