diff --git a/StockSeeker/settings.py b/StockSeeker/settings.py index 1d79082..a0dd136 100644 --- a/StockSeeker/settings.py +++ b/StockSeeker/settings.py @@ -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 -] \ No newline at end of file +] +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,} \ No newline at end of file diff --git a/StockSeeker/views.py b/StockSeeker/views.py index 6175474..2d01355 100644 --- a/StockSeeker/views.py +++ b/StockSeeker/views.py @@ -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):