LP1904036 Login session keys expire; hold patron uses login key
authorBill Erickson <berickxx@gmail.com>
Wed, 26 Jan 2022 18:19:15 +0000 (13:19 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:40 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/core/store.service.ts
Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts
Open-ILS/src/eg2/src/app/staff/catalog/search-templates.component.ts
Open-ILS/src/eg2/src/app/staff/circ/patron/holds.component.ts
Open-ILS/src/eg2/src/app/staff/resolver.service.ts

index 7b239d2..1e279f0 100644 (file)
@@ -54,7 +54,9 @@ export class StoreService {
      * Add a an app-local login session key
      */
     addLoginSessionKey(key: string): void {
-        this.loginSessionKeys.push(key);
+        if (!this.loginSessionKeys.includes(key)) {
+            this.loginSessionKeys.push(key);
+        }
     }
 
     setLocalItem(key: string, val: any, isJson?: boolean): void {
index d181aa3..51a92ed 100644 (file)
@@ -9,6 +9,8 @@ import {BibRecordSummary} from '@eg/share/catalog/bib-record.service';
 import {PatronService} from '@eg/staff/share/patron/patron.service';
 import {StoreService} from '@eg/core/store.service';
 
+const HOLD_FOR_PATRON_KEY = 'eg.circ.patron_hold_target';
+
 /**
  * Shared bits needed by the staff version of the catalog.
  */
@@ -79,7 +81,7 @@ export class StaffCatalogService {
         this.searchContext =
             this.catUrl.fromUrlParams(this.route.snapshot.queryParamMap);
 
-        this.holdForBarcode = this.store.getLocalItem('eg.circ.patron_hold_target');
+        this.holdForBarcode = this.store.getLoginSessionItem(HOLD_FOR_PATRON_KEY);
 
         if (this.holdForBarcode) {
             this.patron.getByBarcode(this.holdForBarcode)
@@ -97,7 +99,7 @@ export class StaffCatalogService {
     clearHoldPatron() {
         this.holdForUser = null;
         this.holdForBarcode = null;
-        this.store.removeLocalItem('eg.circ.patron_hold_target');
+        this.store.removeLoginSessionItem(HOLD_FOR_PATRON_KEY);
         this.holdForChange.emit();
     }
 
index 4697450..75c7a18 100644 (file)
@@ -56,8 +56,6 @@ export class SearchTemplatesComponent extends DialogComponent implements OnInit
         private staffCat: StaffCatalogService,
         private modal: NgbModal) {
         super(modal);
-
-        this.store.addLoginSessionKey(RECENT_SEARCHES_KEY);
     }
 
     ngOnInit() {
index 1574f4e..ffa5be1 100644 (file)
@@ -7,6 +7,8 @@ import {PatronService} from '@eg/staff/share/patron/patron.service';
 import {PatronContextService} from './patron.service';
 import {StoreService} from '@eg/core/store.service';
 
+const HOLD_FOR_PATRON_KEY = 'eg.circ.patron_hold_target';
+
 @Component({
   templateUrl: 'holds.component.html',
   selector: 'eg-patron-holds'
@@ -27,8 +29,7 @@ export class HoldsComponent implements OnInit {
 
     newHold() {
 
-        this.store.setLocalItem(
-            'eg.circ.patron_hold_target',
+        this.store.setLoginSessionItem(HOLD_FOR_PATRON_KEY,
             this.context.summary.patron.card().barcode());
 
         this.router.navigate(['/staff/catalog/search']);
index 2c3a774..08c3a15 100644 (file)
@@ -14,6 +14,14 @@ import {HatchService} from '@eg/core/hatch.service';
 const LOGIN_PATH = '/staff/login';
 const WS_MANAGE_PATH = '/staff/admin/workstation/workstations/manage';
 
+// Define these at the staff application level so they will be honored
+// regardless of which interface is loaded / reloaded / etc.
+const STAFF_LOGIN_SESSION_KEYS = [
+    'eg.circ.patron_hold_target',
+    'eg.catalog.recent_searches',
+    'eg.circ.recent_patrons'
+]
+
 /**
  * Load data used by all staff modules.
  */
@@ -42,6 +50,9 @@ export class StaffResolver implements Resolve<Observable<any>> {
 
         this.hatch.connect();
 
+        STAFF_LOGIN_SESSION_KEYS.forEach(
+            key => this.store.addLoginSessionKey(key));
+
         // Staff cookies stay in /$base/staff/
         // NOTE: storing session data at '/' so it can be shared by
         // Angularjs apps.