LP1880726: Support eg2 cookie user/miker/lp1880726-marc-batch-angular-v2-signoff-cookie_followup
authorMike Rylander <mrylander@gmail.com>
Fri, 11 Sep 2020 16:21:24 +0000 (12:21 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 11 Sep 2020 16:24:47 +0000 (12:24 -0400)
If there is a stale "ses" cookie hanging around when a staff member logs
into the Angular client, it will be sent to the batch MARC edit handler
along with the active "eg.auth.token" cookie.  We should check for and
prefer the latter in this particular code.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/TemplateBatchBibUpdate.pm

index ae91b36..5bd561a 100644 (file)
@@ -55,7 +55,10 @@ sub handler {
     my $r = shift;
     my $cgi = new CGI;
 
-    my $authid = $cgi->cookie('ses') || $cgi->param('ses');
+    my $authid = $cgi->cookie('eg.auth.token') || $cgi->cookie('ses') || $cgi->param('ses');
+    if ($authid =~ /^"(.+)"$/) { # came from eg2 login, is json encoded
+        $authid = $1;
+    }
 
     # Avoid sending the HTML to the caller.  Final response will
     # will just be the cache key or HTTP_BAD_REQUEST on error.