From 314ea41fb02560ff9abe3d184d5fbdf2a5d63f28 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 20 Apr 2018 15:57:24 -0400 Subject: [PATCH] LP#1626157 staff login perm; tidying Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/common.module.ts | 2 +- Open-ILS/src/eg2/src/app/core/perm.service.ts | 2 +- Open-ILS/src/eg2/src/app/migration.module.ts | 5 --- Open-ILS/src/eg2/src/app/share/README | 8 ++-- .../eg2/src/app/share/catalog/catalog.service.ts | 2 +- .../src/app/share/{ => catalog}/unapi.service.ts | 0 .../src/app/share/fm-editor/fm-editor.component.ts | 4 +- .../src/eg2/src/app/share/hello-world.component.ts | 14 ------- .../{ => org-select}/org-select.component.html | 0 .../share/{ => org-select}/org-select.component.ts | 0 .../eg2/src/app/share/{ => util}/audio.service.ts | 0 .../eg2/src/app/staff/catalog/catalog.module.ts | 2 +- Open-ILS/src/eg2/src/app/staff/common.module.ts | 2 +- Open-ILS/src/eg2/src/app/staff/resolver.service.ts | 45 ++++++++++++++++++---- .../src/templates/staff/circ/checkin/t_checkin.tt2 | 10 ----- 15 files changed, 48 insertions(+), 48 deletions(-) rename Open-ILS/src/eg2/src/app/share/{ => catalog}/unapi.service.ts (100%) delete mode 100644 Open-ILS/src/eg2/src/app/share/hello-world.component.ts rename Open-ILS/src/eg2/src/app/share/{ => org-select}/org-select.component.html (100%) rename Open-ILS/src/eg2/src/app/share/{ => org-select}/org-select.component.ts (100%) rename Open-ILS/src/eg2/src/app/share/{ => util}/audio.service.ts (100%) diff --git a/Open-ILS/src/eg2/src/app/common.module.ts b/Open-ILS/src/eg2/src/app/common.module.ts index 4e2021dc8c..8cc94c74e5 100644 --- a/Open-ILS/src/eg2/src/app/common.module.ts +++ b/Open-ILS/src/eg2/src/app/common.module.ts @@ -14,7 +14,7 @@ import {EgAuthService} from '@eg/core/auth.service'; import {EgPermService} from '@eg/core/perm.service'; import {EgPcrudService} from '@eg/core/pcrud.service'; import {EgOrgService} from '@eg/core/org.service'; -import {EgAudioService} from '@eg/share/audio.service'; +import {EgAudioService} from '@eg/share/util/audio.service'; @NgModule({ declarations: [ diff --git a/Open-ILS/src/eg2/src/app/core/perm.service.ts b/Open-ILS/src/eg2/src/app/core/perm.service.ts index a2c439bbec..2e535d14e9 100644 --- a/Open-ILS/src/eg2/src/app/core/perm.service.ts +++ b/Open-ILS/src/eg2/src/app/core/perm.service.ts @@ -4,7 +4,7 @@ import {EgOrgService} from './org.service'; import {EgAuthService} from './auth.service'; interface HasPermAtResult { - [permName: string]: number[]; + [permName: string]: any[]; // org IDs or org unit objects } interface HasPermHereResult { diff --git a/Open-ILS/src/eg2/src/app/migration.module.ts b/Open-ILS/src/eg2/src/app/migration.module.ts index 88c84ae7d5..5c878b54c4 100644 --- a/Open-ILS/src/eg2/src/app/migration.module.ts +++ b/Open-ILS/src/eg2/src/app/migration.module.ts @@ -33,7 +33,6 @@ import {EgOrgService} from '@eg/core/org.service'; // Downgraded components //import {EgDialogComponent} from '@eg/share/dialog/dialog.component'; //import {EgConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; -import {EgHelloWorldComponent} from '@eg/share/hello-world.component'; declare var angular: any; @@ -46,12 +45,10 @@ declare var angular: any; EgCommonModule.forRoot() ], declarations: [ - EgHelloWorldComponent, //EgDialogComponent, //EgConfirmDialogComponent ], entryComponents: [ - EgHelloWorldComponent, //EgDialogComponent, //EgConfirmDialogComponent ] @@ -81,8 +78,6 @@ export class EgMigrationModule { .factory('eg2Pcrud', downgradeInjectable(EgPcrudService)) .factory('eg2Org', downgradeInjectable(EgOrgService)) .factory('ng2Title', downgradeInjectable(Title)) - .directive('eg2HelloWorld', - downgradeComponent({component: EgHelloWorldComponent})) /* .directive('eg2ConfirmDialog', downgradeComponent({component: EgConfirmDialogComponent})) diff --git a/Open-ILS/src/eg2/src/app/share/README b/Open-ILS/src/eg2/src/app/share/README index 1a8b6e1646..9da6f8a11a 100644 --- a/Open-ILS/src/eg2/src/app/share/README +++ b/Open-ILS/src/eg2/src/app/share/README @@ -1,7 +1,5 @@ -Common Angular services and associated types/classes. - -This collection of services MIGHT be used by practically all applications. -They are NOT automatically imported/exported by the base module and should -be loaded within the requesting application as needed. +Shared Angular services, components, directives, and associated classes. +These items are NOT automatically imported to the base module. Import +as needed. diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts index f59c6c12e1..8b0483f3e7 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts @@ -1,6 +1,6 @@ import {Injectable} from '@angular/core'; import {EgOrgService} from '@eg/core/org.service'; -import {EgUnapiService} from '@eg/share/unapi.service'; +import {EgUnapiService} from '@eg/share/catalog/unapi.service'; import {EgIdlObject} from '@eg/core/idl.service'; import {EgNetService} from '@eg/core/net.service'; import {EgPcrudService} from '@eg/core/pcrud.service'; diff --git a/Open-ILS/src/eg2/src/app/share/unapi.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/unapi.service.ts similarity index 100% rename from Open-ILS/src/eg2/src/app/share/unapi.service.ts rename to Open-ILS/src/eg2/src/app/share/catalog/unapi.service.ts diff --git a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts index 3ba94a3c47..5e17f6f60d 100644 --- a/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts +++ b/Open-ILS/src/eg2/src/app/share/fm-editor/fm-editor.component.ts @@ -12,7 +12,7 @@ interface CustomFieldTemplate { // Allow the caller to pass in a free-form context blob to // be addedto the caller's custom template context, along // with our stock context. - context?: [fields: string]: any + context?: {[fields: string]: any} } interface CustomFieldContext { @@ -268,7 +268,7 @@ export class FmRecordEditorComponent // Returns a context object to be inserted into a custom // field template. - customTemplateFieldContext(fieldDef: any): FmEditorCustomFieldContext { + customTemplateFieldContext(fieldDef: any): CustomFieldContext { return Object.assign( { record : this.record, field: fieldDef // from this.fields diff --git a/Open-ILS/src/eg2/src/app/share/hello-world.component.ts b/Open-ILS/src/eg2/src/app/share/hello-world.component.ts deleted file mode 100644 index 92daf1ccfa..0000000000 --- a/Open-ILS/src/eg2/src/app/share/hello-world.component.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {Component, Input} from '@angular/core'; - -@Component({ - selector: 'eg-hello-world', - template: ` -
Hello, World {{message}}!
- ` -}) -export class EgHelloWorldComponent { - @Input() public message: string; - constructor() {} -} - - diff --git a/Open-ILS/src/eg2/src/app/share/org-select.component.html b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.html similarity index 100% rename from Open-ILS/src/eg2/src/app/share/org-select.component.html rename to Open-ILS/src/eg2/src/app/share/org-select/org-select.component.html diff --git a/Open-ILS/src/eg2/src/app/share/org-select.component.ts b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts similarity index 100% rename from Open-ILS/src/eg2/src/app/share/org-select.component.ts rename to Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts diff --git a/Open-ILS/src/eg2/src/app/share/audio.service.ts b/Open-ILS/src/eg2/src/app/share/util/audio.service.ts similarity index 100% rename from Open-ILS/src/eg2/src/app/share/audio.service.ts rename to Open-ILS/src/eg2/src/app/share/util/audio.service.ts diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts index 7438ec9bae..4bb63fd33c 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts @@ -1,6 +1,6 @@ import {NgModule} from '@angular/core'; import {EgStaffCommonModule} from '@eg/staff/common.module'; -import {EgUnapiService} from '@eg/share/unapi.service'; +import {EgUnapiService} from '@eg/share/catalog/unapi.service'; import {EgCatalogRoutingModule} from './routing.module'; import {EgCatalogService} from '@eg/share/catalog/catalog.service'; import {EgCatalogUrlService} from '@eg/share/catalog/catalog-url.service'; diff --git a/Open-ILS/src/eg2/src/app/staff/common.module.ts b/Open-ILS/src/eg2/src/app/staff/common.module.ts index 762c1aa877..c8aeb1d152 100644 --- a/Open-ILS/src/eg2/src/app/staff/common.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/common.module.ts @@ -1,7 +1,7 @@ import {NgModule, ModuleWithProviders} from '@angular/core'; import {EgCommonModule} from '@eg/common.module'; import {EgStaffBannerComponent} from './share/staff-banner.component'; -import {EgOrgSelectComponent} from '@eg/share/org-select.component'; +import {EgOrgSelectComponent} from '@eg/share/org-select/org-select.component'; import {EgDialogComponent} from '@eg/share/dialog/dialog.component'; import {EgConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; import {EgPromptDialogComponent} from '@eg/share/dialog/prompt.component'; 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 8f2fe5a0fe..301979fb18 100644 --- a/Open-ILS/src/eg2/src/app/staff/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/resolver.service.ts @@ -6,6 +6,7 @@ import {Router, Resolve, RouterStateSnapshot, import {EgStoreService} from '@eg/core/store.service'; import {EgNetService} from '@eg/core/net.service'; import {EgAuthService, EgAuthWsState} from '@eg/core/auth.service'; +import {EgPermService} from '@eg/core/perm.service'; const LOGIN_PATH = '/staff/login'; const WS_MANAGE_PATH = '/staff/admin/workstation/workstations/manage'; @@ -25,7 +26,8 @@ export class EgStaffResolver implements Resolve> { private ngLocation: Location, private store: EgStoreService, private net: EgNetService, - private auth: EgAuthService + private auth: EgAuthService, + private perm: EgPermService, ) {} resolve( @@ -50,12 +52,20 @@ export class EgStaffResolver implements Resolve> { this.auth.testAuthToken().then( tokenOk => { console.debug('EgStaffResolver: authtoken verified'); - this.auth.verifyWorkstation().then( - wsOk => { - this.loadStartupData() - .then(ok => this.observer.complete()) - }, - wsNotOk => this.handleInvalidWorkstation(path) + this.confirmStaffPerms().then( + hasPerms => { + this.auth.verifyWorkstation().then( + wsOk => { + this.loadStartupData() + .then(ok => this.observer.complete()) + }, + wsNotOk => this.handleInvalidWorkstation(path) + ); + }, + hasNotPerms => { + this.observer.error( + 'User does not have staff permissions'); + } ); }, tokenNotOk => this.handleInvalidToken(state) @@ -64,6 +74,27 @@ export class EgStaffResolver implements Resolve> { return observable; } + + // Confirm the user has the STAFF_LOGIN permission anywhere before + // allowing the staff sub-tree to load. This will prevent users + // with valid, non-staff authtokens from attempting to connect and + // subsequently getting redirected to the workstation admin page + // (since they won't have a valid WS either). + confirmStaffPerms(): Promise { + return new Promise((resolve, reject) => { + this.perm.hasWorkPermAt(['STAFF_LOGIN']).then( + permMap => { + if (permMap.STAFF_LOGIN.length) { + resolve('perm check OK'); + } else { + reject('perm check faield'); + } + } + ); + }); + } + + // A page that's not the login page was requested without a // valid auth token. Send the caller back to the login page. handleInvalidToken(state: RouterStateSnapshot): void { diff --git a/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 b/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 index 974f08a402..42d6e67d60 100644 --- a/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 +++ b/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 @@ -5,16 +5,6 @@ - - - -
-- 2.11.0