From 5c634ee597efec48dd54c55ace5fcac2b93c40c3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Mar 2024 10:08:16 +0100 Subject: [PATCH] Bug 36349: Fix AutoSelfCheckAllowed Move the check to C4::Auth. Yes, it's not nice, I didn't expect to add exception to this code, and it's adding more ugly code to get_template_and_user, but... Suggestions welcome! Signed-off-by: Owen Leonard Signed-off-by: David Cook Signed-off-by: Katrin Fischer --- C4/Auth.pm | 18 +++++++++++++----- opac/sco/sco-main.pl | 8 -------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index a8c21740f0..86ddd3baf0 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -183,11 +183,19 @@ sub get_template_and_user { $in->{'query'}, ); - my $request_method = $in->{query}->request_method // q{}; - unless ( $request_method eq 'POST' && $in->{query}->param('op') eq 'cud-login' ) { - for my $v ( qw( login_userid login_password ) ) { - $in->{query}->param($v, '') - if $in->{query}->param($v); + 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'] ); + } else { + my $request_method = $in->{query}->request_method // q{}; + unless ( $request_method eq 'POST' && $in->{query}->param('op') eq 'cud-login' ) { + for my $v (qw( login_userid login_password )) { + $in->{query}->param( $v, '' ) + if $in->{query}->param($v); + } } } diff --git a/opac/sco/sco-main.pl b/opac/sco/sco-main.pl index a4a05f793e..a7fcb24d8f 100755 --- a/opac/sco/sco-main.pl +++ b/opac/sco/sco-main.pl @@ -61,14 +61,6 @@ unless ( in_iprange(C4::Context->preference('SelfCheckAllowByIPRanges')) ) { exit; } -if (C4::Context->preference('AutoSelfCheckAllowed')) -{ - my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID'); - my $AutoSelfCheckPass = C4::Context->preference('AutoSelfCheckPass'); - $query->param(-name=>'userid',-values=>[$AutoSelfCheckID]); - $query->param(-name=>'password',-values=>[$AutoSelfCheckPass]); - $query->param(-name=>'koha_login_context',-values=>['sco']); -} $query->param(-name=>'sco_user_login',-values=>[1]); my ( $template, $loggedinuser, $cookie ) = get_template_and_user( -- 2.39.5