Bug 35918: Fix auto library connect (AutoLocation)
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 26 Jan 2024 07:58:17 +0000 (08:58 +0100)
committerWainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
Wed, 27 Mar 2024 05:30:13 +0000 (05:30 +0000)
commit7b3a8e5c46d3c635a1ddcfa4cd6053c5669d36e6
tree2094051430da03b1339b012d0ea85e2db6a6a4dd
parentf6950c001aa0b5aa78d286544d87d771fec545a8
Bug 35918: Fix auto library connect (AutoLocation)

This code is a bit weird, its purpose it to auto select the library depending on the IP.
A problem appears if the same IP is used, then the user's choice will
might be overwritten randomly by another library.

To recreate the problem:
Turn on AutoLocation
Use koha/koha @CPL for test
And the following config:
*************************** 1. row ***************************
branchcode: CPL
branchname: Centerville
  branchip: 172.18.0.1
*************************** 2. row ***************************
branchcode: FFL
branchname: Fairfield
  branchip: 172.18.0.1
*************************** 3. row ***************************
branchcode: FPL
branchname: Fairview
  branchip: 172.18.0.4

Connect and select CPL. Randomly FFL will be picked instead.

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Tested this on top of 35890 and 35904 because git bz said they were required dependencies.
Figured out the IP Koha was seeing me as coming from in /var/log/koha/kohadev/plack.log.
Added that IP to the branchip for Centerville, Fairfield and Fairview. Set AutoLocation = Yes.
After this I could recreate the problem: If i left the "Library" field in the login screen
at "My Library" I got logged into a random library selected from the three i had set
branchip for. Applying the patches fixed this, as expected.
Tests pass, with AutoLocation off.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz>
C4/Auth.pm