LP1901930 Improve existing session detection
authorBill Erickson <berickxx@gmail.com>
Wed, 9 Jun 2021 21:56:41 +0000 (17:56 -0400)
committerBill Erickson <berickxx@gmail.com>
Mon, 28 Nov 2022 20:00:35 +0000 (15:00 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/SIP2/Session.pm

index b767ce8..7974990 100644 (file)
@@ -130,8 +130,7 @@ sub set_ils_account {
         login_type => 'staff'
     };
 
-    $args->{workstation} = $account->workstation->name
-        if $account->workstation;
+    $args->{workstation} = $account->workstation->name if $account->workstation;
 
     my $auth = $U->simplereq(
         'open-ils.auth_internal',
@@ -160,6 +159,12 @@ sub set_ils_account {
 
     $e->xact_begin;
 
+    # Always confirm a matching session does not exist before attempting
+    # to create one.
+    $ses = $e->retrieve_sip_session([
+        $seskey, {flesh => 1, flesh_fields => {sipses => ['account']}}])
+        unless $ses;
+
     if ($ses) {
         # ILS token expired on an existing SIP session.
         # Update the session to use the new token.