https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44312 --- Comment #2 from David Nind <david@davidnind.com> --- Created attachment 212805 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=212805&action=edit Bug 44312: Don't attribute failed SIP logins to the previous terminal Bug 42847 made login_core clear the leftover session keys on $server before authenticating, but C4::Context->userenv from a previous successful login on the same preforked worker was left in place. When AuthFailureLog (or BorrowersLog) is enabled, a failed SIP login is then logged with action_logs.user set to the previously authenticated terminal instead of 0. This patch unsets the userenv along with the session keys, so only a successful api_auth re-establishes it. A failed login is now logged with user 0, the same as a failed OPAC or staff interface login. Test plan: 1) Enable the AuthFailureLog and AuthSuccessLog system preferences 2) Make sure two SIP accounts exist in SIPconfig.xml with matching staff patrons, e.g. 'koha' (password 'koha') and 'term1' (password 'term1') in KTD, then restart SIP: koha-sip --restart kohadev 3) Connect to the SIP server (telnet localhost 6001 in KTD) and send a successful login for the first account: 9300CNkoha|COkoha|CPCPL| Note you get 941 4) On the same connection (or a new one), send a bad login for the second account: 9300CNterm1|COWRONG|CPCPL| Note you get 940 5) Check the action logs: SELECT user, module, action, object, info FROM action_logs WHERE module IN ('AUTH','MEMBERS') ORDER BY action_id DESC LIMIT 4; 6) Note the AUTH FAILURE row for term1 (and the MEMBERS MODIFY row for login_attempts) has 'user' set to the koha patron's borrowernumber 7) prove t/db_dependent/SIP/MsgType.t 8) Note the new subtest fails 9) Apply this patch and restart SIP 10) prove t/db_dependent/SIP/MsgType.t 11) Note the tests pass 12) Repeat steps 3-5 13) Note the failure rows now have user 0 14) Log in as term1 with the right password and note it still works (941) and is logged under term1's borrowernumber Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.