From dec7b3dabf97a3f6a2ec04048e795dfae06a9c82 Mon Sep 17 00:00:00 2001 From: Horilla Date: Thu, 8 Jan 2026 12:07:35 +0530 Subject: [PATCH] [FIX] BASE: Fix company logo not rendering in payslip PDF and print preview --- base/views.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/base/views.py b/base/views.py index 082b3434b..b2d9f3862 100644 --- a/base/views.py +++ b/base/views.py @@ -7734,20 +7734,25 @@ def protected_media(request, path): "/recruitment/open-recruitments/", "/recruitment/candidate-self-status-tracking/", ] - exempted_folders = ["base/icon/"] + + # EXACT folder where company logos exist + exempted_folders = [ + "base/company/icon/", + ] media_path = os.path.join(settings.MEDIA_ROOT, path) + if not os.path.exists(media_path): raise Http404("File not found") referer_path = urlparse(request.META.get("HTTP_REFERER", "")).path - # Try Bearer token auth + # JWT support (your existing logic) jwt_user = is_jwt_token_valid(request.META.get("HTTP_AUTHORIZATION", "")) - # Access control logic + # Access control if referer_path not in public_pages and not any( - path.startswith(f) for f in exempted_folders + path.startswith(folder) for folder in exempted_folders ): if not request.user.is_authenticated and not jwt_user: messages.error( @@ -7756,4 +7761,5 @@ def protected_media(request, path): ) return redirect("login") + # Allow logo to be served publicly return FileResponse(open(media_path, "rb"))