From 8322b89a82fc7387cca0532a5bab8603cbc72737 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 20 Apr 2022 12:08:52 -0400 Subject: [PATCH] LP1969641 Show useful lack of staff working location message When a user logs into the staff client that has STAFF_LOGIN permissions, but no working locations, show a message to this affect instead of resulting in a blank page. Signed-off-by: Bill Erickson Signed-off-by: John Amundson Signed-off-by: Galen Charlton --- .../src/app/staff/login-not-allowed.component.html | 14 ++++++++ .../src/app/staff/login-not-allowed.component.ts | 35 ++++++++++++++++++++ Open-ILS/src/eg2/src/app/staff/resolver.service.ts | 6 ++-- Open-ILS/src/eg2/src/app/staff/routing.module.ts | 8 ++++ Open-ILS/src/eg2/src/app/staff/staff.module.ts | 2 + 5 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/login-not-allowed.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/login-not-allowed.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/login-not-allowed.component.html b/Open-ILS/src/eg2/src/app/staff/login-not-allowed.component.html new file mode 100644 index 0000000..ab30f89 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/login-not-allowed.component.html @@ -0,0 +1,14 @@ +
+
+
+ + No Working Locations Set for Staff Account + {{username}}. + +
+
+ +
+
diff --git a/Open-ILS/src/eg2/src/app/staff/login-not-allowed.component.ts b/Open-ILS/src/eg2/src/app/staff/login-not-allowed.component.ts new file mode 100644 index 0000000..32798c8 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/login-not-allowed.component.ts @@ -0,0 +1,35 @@ +import {Component, OnInit, AfterViewInit} from '@angular/core'; +import {Location} from '@angular/common'; +import {Router, ActivatedRoute} from '@angular/router'; +import {AuthService, AuthWsState} from '@eg/core/auth.service'; + +@Component({ + templateUrl : './login-not-allowed.component.html' +}) + +export class StaffLoginNotAllowedComponent implements OnInit, AfterViewInit { + + username: string; + userId: number; + + constructor( + private router: Router, + private route: ActivatedRoute, + private ngLocation: Location, + private auth: AuthService + ) {} + + ngOnInit() { + this.username = this.auth.user().usrname(); + this.userId = this.auth.user().id(); + } + + ngAfterViewInit() { + // Timeout allows us to force the logout, without the UI + // sending is immediately back to the login page. + setTimeout(() => this.auth.logout()); + } +} + + + 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 b8d224c..225b931 100644 --- a/Open-ILS/src/eg2/src/app/staff/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/resolver.service.ts @@ -61,7 +61,7 @@ export class StaffResolver implements Resolve> { // Not sure how to get the path without params... using this for now. const path = state.url.split('?')[0]; - if (path === '/staff/login') { + if (path === '/staff/login' || path === '/staff/login-not-allowed') { return of(true); } @@ -85,8 +85,8 @@ export class StaffResolver implements Resolve> { ); }, hasNotPerms => { - this.observer.error( - 'User does not have staff permissions'); + this.router.navigate(['/staff/login-not-allowed']); + this.observer.error('User does not have staff permissions'); } ); }, diff --git a/Open-ILS/src/eg2/src/app/staff/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/routing.module.ts index d7981d7..e34324a 100644 --- a/Open-ILS/src/eg2/src/app/staff/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/routing.module.ts @@ -3,6 +3,7 @@ import {RouterModule, Routes} from '@angular/router'; import {StaffResolver} from './resolver.service'; import {StaffComponent} from './staff.component'; import {StaffLoginComponent} from './login.component'; +import {StaffLoginNotAllowedComponent} from './login-not-allowed.component'; import {StaffSplashComponent} from './splash.component'; import {AboutComponent} from './about.component'; @@ -33,6 +34,13 @@ const routes: Routes = [{ path: 'login', component: StaffLoginComponent }, { + // Attempt to login to the staff client w/o the needed permissions + // or work org unit. + path: 'login-not-allowed', + component: StaffLoginNotAllowedComponent + }, { + // Attempt to fetch a specific page the user does not have + // access to. path: 'no_permission', component: StaffSplashComponent }, { diff --git a/Open-ILS/src/eg2/src/app/staff/staff.module.ts b/Open-ILS/src/eg2/src/app/staff/staff.module.ts index 34bf589..ba3c6d6 100644 --- a/Open-ILS/src/eg2/src/app/staff/staff.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/staff.module.ts @@ -7,6 +7,7 @@ import {StaffNavComponent} from './nav.component'; import {StaffLoginComponent} from './login.component'; import {StaffSplashComponent, AutofocusDirective} from './splash.component'; import {AboutComponent} from './about.component'; +import {StaffLoginNotAllowedComponent} from './login-not-allowed.component'; @NgModule({ declarations: [ @@ -15,6 +16,7 @@ import {AboutComponent} from './about.component'; StaffSplashComponent, AutofocusDirective, StaffLoginComponent, + StaffLoginNotAllowedComponent, AboutComponent ], imports: [ -- 1.7.2.5