jwt changes

This commit is contained in:
Léo 2025-01-13 22:47:36 +01:00
parent edd9b25545
commit ff3273a366
2 changed files with 12 additions and 5 deletions

View File

@ -10,7 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""
from pathlib import Path
from datetime import timedelta
from decouple import config
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@ -144,4 +144,11 @@ SPECTACULAR_SETTINGS = {
}
CORS_ALLOWED_ORIGINS = [
"http://localhost:5173", # Remplace par l'URL de ton front-end
]
]
CORS_ALLOW_CREDENTIALS = True
SIMPLE_JWT = {
'ACCESS_TOKEN_LIFETIME': timedelta(minutes=5),
'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
'ROTATE_REFRESH_TOKENS': True,
'BLACKLIST_AFTER_ROTATION': True,}

View File

@ -33,12 +33,12 @@ class CreateUser(generics.CreateAPIView):
}, status=status.HTTP_201_CREATED)
class UserInfo(generics.ListAPIView):
class UserInfo(generics.RetrieveAPIView):
permission_classes = [IsAuthenticated]
serializer_class = UserSerializer
def get_queryset(self):
return User.objects.filter(username=self.request.user)
def get_object(self):
return self.request.user
class ProductView(viewsets.ModelViewSet):