From 0a361acd15e8a9bd8edcce4e39ad9e065852e9df Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 26 Jan 2022 13:19:15 -0500 Subject: [PATCH] LP1904036 Login session keys expire; hold patron uses login key Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg Signed-off-by: Galen Charlton --- Open-ILS/src/eg2/src/app/core/store.service.ts | 4 +++- .../eg2/src/app/staff/catalog/catalog.service.ts | 6 ++++-- .../staff/catalog/search-templates.component.ts | 2 -- .../src/app/staff/circ/patron/holds.component.ts | 5 +++-- Open-ILS/src/eg2/src/app/staff/resolver.service.ts | 11 +++++++++++ 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/core/store.service.ts b/Open-ILS/src/eg2/src/app/core/store.service.ts index 7b239d2..1e279f0 100644 --- a/Open-ILS/src/eg2/src/app/core/store.service.ts +++ b/Open-ILS/src/eg2/src/app/core/store.service.ts @@ -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 { diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts index d181aa3..51a92ed 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts @@ -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(); } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-templates.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/search-templates.component.ts index 4697450..75c7a18 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-templates.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-templates.component.ts @@ -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() { diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/holds.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/holds.component.ts index 1574f4e..ffa5be1 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/holds.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/holds.component.ts @@ -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']); diff --git a/Open-ILS/src/eg2/src/app/staff/resolver.service.ts b/Open-ILS/src/eg2/src/app/staff/resolver.service.ts index 2c3a774..08c3a15 100644 --- a/Open-ILS/src/eg2/src/app/staff/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/resolver.service.ts @@ -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> { 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. -- 1.7.2.5