From 0fdb92761f95724caa6c78900971a96df409b2b2 Mon Sep 17 00:00:00 2001
From: Alex Buckley <alexbuckley@catalyst.net.nz>
Date: Fri, 22 Apr 2022 16:13:17 +1200
Subject: [PATCH] Bug 30444: (follow-up) WIP:

Don't re-direct infinite loop if SelfCheckoutByLogin not equal to 'shibboleth'

Test plan:
1. On a Koha setup to do Shibboleth set the following sysprefs:
- OPACShibOnly = "Don't allow"
- AutoSelfCheckAllowed = Allow
- AutoSelfCheckID and AutoSelfCheckPass = The username and password of a
patron with 'self_checkout_module' sub-permission enabled
- SelfCheckoutByLogin = 'cardnumber'
2. Visit the self checkout page, confirm it does not indefinitely loop
3. Change SelfCheckoutbyLogin = 'username and password'
4. Repeat step 2 and confirm the same results
5. Change SelfCheckoutByLogin = 'shibboleth'
6. Repeat step 2 and confirm the same results

Sponsored-by: Catalyst IT
---
 C4/Auth.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/C4/Auth.pm b/C4/Auth.pm
index c1c27e0eb95..1f126a4fac7 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -1456,7 +1456,7 @@ sub checkauth {
 
     if ($shib) {
         #If shibOnly is enabled just go ahead and redirect directly
-        if ( (($type eq 'opac') && C4::Context->preference('OPACShibOnly')) || (($type ne 'opac') && C4::Context->preference('staffShibOnly')) ) {
+        if ( (($type eq 'opac') && C4::Context->preference('OPACShibOnly') && !$query->param('sco_user_login') ) || (($type ne 'opac') && C4::Context->preference('staffShibOnly')) ) {
             my $redirect_url = login_shib_url( $query );
             print $query->redirect( -uri => "$redirect_url", -status => 303 );
             safe_exit;
-- 
2.20.1