Bugzilla – Attachment 189889 Details for
Bug 21250
Auto-self-checkout not fully compatible with multi-branch library setup
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21250: Allow multi-branch variants of AutoSelfCheckID
Bug-21250-Allow-multi-branch-variants-of-AutoSelfC.patch (text/plain), 4.83 KB, created by
David Cook
on 2025-11-22 01:57:18 UTC
(
hide
)
Description:
Bug 21250: Allow multi-branch variants of AutoSelfCheckID
Filename:
MIME Type:
Creator:
David Cook
Created:
2025-11-22 01:57:18 UTC
Size:
4.83 KB
patch
obsolete
>From 5a87fb5b103111e0793bfde5a0fb2e202b2a95e8 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Sat, 22 Nov 2025 01:46:54 +0000 >Subject: [PATCH] Bug 21250: Allow multi-branch variants of AutoSelfCheckID > >This change allows multiple AutoSelfCheck users so that >different branches can use different users which will apply >the correct circulation and fines rules, locations for circs, >etc. > >Test plan: >0. Apply the patch >1. koha-plack --restart kohadev >2. Set up different users that share the same userid as the >value in AutoSelfCheckID, but with the target branch code >appended to the end of the userid. Ensure that the passwords >and permissions are the same for all of these users. >3. Visit a branch specific SCO. For example: >/cgi-bin/koha/sco/sco-main.pl?branch=FPL >4. If you have a user like "self_checkoutFPL", then it should >auto-login. The session for this user should be preserved >for subsequent actions so long as the HTTP cookie is retained >--- > C4/Auth.pm | 52 ++++++++++++++++++++++++++++++++++++++++++---------- > 1 file changed, 42 insertions(+), 10 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 39f3889867..0971695499 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -214,9 +214,27 @@ sub get_template_and_user { > if ( C4::Context->preference('AutoSelfCheckAllowed') && $in->{template_name} =~ m|sco/| ) { > my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID'); > my $AutoSelfCheckPass = C4::Context->preference('AutoSelfCheckPass'); >- $in->{query}->param( -name => 'login_userid', -values => [$AutoSelfCheckID] ); >- $in->{query}->param( -name => 'login_password', -values => [$AutoSelfCheckPass] ); >- $in->{query}->param( -name => 'koha_login_context', -values => ['sco'] ); >+ >+ my $sco_branch = $in->{query}->param('branch'); >+ if ($sco_branch) { >+ $AutoSelfCheckID .= $sco_branch; >+ } >+ my $sco_cookie = $in->{query}->cookie("CGISESSID"); >+ my $sco_already_authenticated; >+ if ($sco_cookie) { >+ my $sco_session = get_session($sco_cookie); >+ if ($sco_session) { >+ my $is_sco_user = $sco_session->param('sco_user'); >+ if ($is_sco_user) { >+ $sco_already_authenticated = 1; >+ } >+ } >+ } >+ if ( $sco_branch || ( !$sco_already_authenticated ) ) { >+ $in->{query}->param( -name => 'login_userid', -values => [$AutoSelfCheckID] ); >+ $in->{query}->param( -name => 'login_password', -values => [$AutoSelfCheckPass] ); >+ $in->{query}->param( -name => 'koha_login_context', -values => ['sco'] ); >+ } > } else { > my $request_method = $in->{query}->request_method // q{}; > unless ( $request_method eq 'POST' && $in->{query}->param('op') eq 'cud-login' ) { >@@ -271,13 +289,7 @@ sub get_template_and_user { > if ( > # If the user logged in is the SCO user and they try to go out of the SCO module, > # log the user out removing the CGISESSID cookie >- $in->{template_name} !~ m|sco/| >- && $in->{template_name} !~ m|errors/errorpage.tt| >- && ( >- $is_sco_user >- || ( C4::Context->preference('AutoSelfCheckID') >- && $user eq C4::Context->preference('AutoSelfCheckID') ) >- ) >+ $in->{template_name} !~ m|sco/| && $in->{template_name} !~ m|errors/errorpage.tt| && ($is_sco_user) > ) > { > $kick_out = 1; >@@ -1166,10 +1178,30 @@ sub checkauth { > } else { > my $retuserid; > >+ #Support multi-branch AutoSelfCheckID >+ my $sco_multi; >+ my $sco_multi_branch = $query->param('branch'); >+ if ($sco_multi_branch) { >+ >+ #Validate that the branch belongs to a real library >+ my $sco_library = Koha::Libraries->find($sco_multi_branch); >+ if ($sco_library) { >+ my $sco_syspref = C4::Context->preference('AutoSelfCheckID'); >+ if ($sco_syspref) { >+ if ( $q_userid eq ( $sco_syspref . $sco_multi_branch ) ) { >+ $sco_multi = 1; >+ } >+ } >+ } >+ } >+ >+ #/Support multi-branch AutoSelfCheckID >+ > if ( > $request_method eq 'POST' > || ( C4::Context->preference('AutoSelfCheckID') > && $q_userid eq C4::Context->preference('AutoSelfCheckID') ) >+ || ($sco_multi) > ) > { > my $patron; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21250
: 189889