Skip to content

Commit 8c4036e

Browse files
committed
feat: #309 - Disable JWT auth for newly public endpoints
1 parent 2883471 commit 8c4036e

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

frontend/src/api/apiClient.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { FormValues } from "../pages/Feedback/FeedbackForm";
33
import { Conversation } from "../components/Header/Chat";
44
const baseURL = import.meta.env.VITE_API_BASE_URL;
55

6-
export const publicApi = axios.create({
7-
baseURL
8-
});
6+
export const publicApi = axios.create({ baseURL });
97

108
export const adminApi = axios.create({
119
baseURL,

server/api/views/conversations/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from rest_framework.response import Response
22
from rest_framework import viewsets, status
33
from rest_framework.decorators import action
4-
from rest_framework.permissions import IsAuthenticated
4+
from rest_framework.permissions import AllowAny
55
from rest_framework.exceptions import APIException
66
from django.http import JsonResponse
77
from bs4 import BeautifulSoup
@@ -81,7 +81,7 @@ def __init__(self, detail=None, code=None):
8181

8282
class ConversationViewSet(viewsets.ModelViewSet):
8383
serializer_class = ConversationSerializer
84-
permission_classes = [IsAuthenticated]
84+
permission_classes = [AllowAny]
8585

8686
def get_queryset(self):
8787
return Conversation.objects.filter(user=self.request.user)

server/api/views/feedback/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
from rest_framework.permissions import AllowAny
22
from rest_framework.views import APIView
33
from rest_framework.response import Response
44
from rest_framework import status
@@ -8,6 +8,8 @@
88

99

1010
class FeedbackView(APIView):
11+
permission_classes = [AllowAny]
12+
1113
def post(self, request, *args, **kwargs):
1214
serializer = FeedbackSerializer(data=request.data)
1315
if serializer.is_valid():

server/api/views/listMeds/views.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from rest_framework import status
2+
from rest_framework.permissions import AllowAny
23
from rest_framework.response import Response
34
from rest_framework.views import APIView
45

@@ -21,6 +22,8 @@
2122

2223

2324
class GetMedication(APIView):
25+
permission_classes = [AllowAny]
26+
2427
def post(self, request):
2528
data = request.data
2629
state_query = data.get('state', '')
@@ -67,6 +70,8 @@ def post(self, request):
6770

6871

6972
class ListOrDetailMedication(APIView):
73+
permission_classes = [AllowAny]
74+
7075
def get(self, request):
7176
name_query = request.query_params.get('name', None)
7277
if name_query:
@@ -95,15 +100,15 @@ def post(self, request):
95100
name = data.get('name', '').strip()
96101
benefits = data.get('benefits', '').strip()
97102
risks = data.get('risks', '').strip()
98-
103+
99104
# Validate required fields
100105
if not name:
101106
return Response({'error': 'Medication name is required'}, status=status.HTTP_400_BAD_REQUEST)
102107
if not benefits:
103108
return Response({'error': 'Medication benefits are required'}, status=status.HTTP_400_BAD_REQUEST)
104109
if not risks:
105110
return Response({'error': 'Medication risks are required'}, status=status.HTTP_400_BAD_REQUEST)
106-
111+
107112
# Check if medication already exists
108113
if Medication.objects.filter(name=name).exists():
109114
return Response({'error': f'Medication "{name}" already exists'}, status=status.HTTP_400_BAD_REQUEST)
@@ -123,11 +128,11 @@ class DeleteMedication(APIView):
123128
def delete(self, request):
124129
data = request.data
125130
name = data.get('name', '').strip()
126-
131+
127132
# Validate required fields
128133
if not name:
129134
return Response({'error': 'Medication name is required'}, status=status.HTTP_400_BAD_REQUEST)
130-
135+
131136
# Check if medication exists and delete
132137
try:
133138
medication = Medication.objects.get(name=name)

0 commit comments

Comments
 (0)