From cb8dfdde4cfa2f471451ad5d8ca01f1fc369d652 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Thu, 3 Dec 2020 08:25:36 +0100 Subject: [PATCH] Fix #1739 (opds download with anonymous browsing enabled) --- cps/opds.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cps/opds.py b/cps/opds.py index 4d9b08b2..9cba6fa5 100644 --- a/cps/opds.py +++ b/cps/opds.py @@ -386,7 +386,9 @@ def feed_shelf(book_id): def opds_download_link(book_id, book_format): # I gave up with this: With enabled ldap login, the user doesn't get logged in, therefore it's always guest # workaround, loading the user from the request and checking it's download rights here - if not load_user_from_request(request).role_download(): + # in case of anonymous browsing user is None + user = load_user_from_request(request) + if not user or not user.role_download(): return abort(403) if "Kobo" in request.headers.get('User-Agent'): client = "kobo"