Skip to content

Commit d6126a6

Browse files
Merge pull request #139 from null-open-security-community/company_fix
not exist sending blank data
2 parents 3b04b04 + 0021adc commit d6126a6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

apps/jobs/views.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,18 @@ def create(self, request, *args, **kwargs):
349349

350350
@action(detail=False, methods=["get"])
351351
def me(self, request):
352-
if request.user.is_anonymous or not request.user.is_profile_completed:
352+
if request.user.is_anonymous:
353353
raise exceptions.PermissionDenied()
354354

355-
# fetch user profile which has the company associated
356-
company = Company.objects.get(creator=request.user)
357-
358-
return Response(self.serializer_class(company).data)
355+
try:
356+
# Attempt to fetch the company associated with the user
357+
company = Company.objects.get(creator=request.user)
358+
serializer = self.serializer_class(company)
359+
return Response(serializer.data)
360+
except Company.DoesNotExist:
361+
# Return an empty serializer when no company is found
362+
serializer = self.serializer_class()
363+
return Response(serializer.data, status=status.HTTP_200_OK)
359364

360365

361366
class ContactUsViewSet(viewsets.ModelViewSet):

0 commit comments

Comments
 (0)