Skip to content

Commit

Permalink
Merge pull request #45 from NatLibFi/feature/simplye-263/custom-lane-…
Browse files Browse the repository at this point in the history
…management

Override library for authenticated patron requests
  • Loading branch information
attemoi authored Apr 15, 2024
2 parents 2ab9006 + 265e070 commit 370ba4c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions api/controller/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,16 @@ def library_for_request(self, library_short_name):
if not library:
return LIBRARY_NOT_FOUND
flask.request.library = library

# Finland: For authenticated patrons, override the library defined in the request
# and use the library assigned to that patron.
#
# This is a bit sketchy as the authentication requires library to be set already.
# So in practice the library in the URL path is used for authentication, but after
# that the request is performed with the patron's assigned library.
patron = self.manager.index_controller.authenticated_patron_from_request()
if isinstance(patron, Patron):
library = patron.library
flask.request.library = patron.library

return library

0 comments on commit 370ba4c

Please sign in to comment.