LP1969641 Show useful lack of staff working location message
authorBill Erickson <berickxx@gmail.com>
Wed, 20 Apr 2022 16:08:52 +0000 (12:08 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Tue, 14 Feb 2023 14:31:41 +0000 (09:31 -0500)
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 <berickxx@gmail.com>
Signed-off-by: John Amundson <jamundson@cwmars.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>

Open-ILS/src/eg2/src/app/staff/login-not-allowed.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/login-not-allowed.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/resolver.service.ts
Open-ILS/src/eg2/src/app/staff/routing.module.ts
Open-ILS/src/eg2/src/app/staff/staff.module.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 (file)
index 0000000..ab30f89
--- /dev/null
@@ -0,0 +1,14 @@
+<div class="container pt-5">
+  <div class="col-lg-6 offset-lg-3">
+    <div class="alert alert-danger">
+      <span i18n>
+        No Working Locations Set for Staff Account 
+          <a href="/eg/staff/circ/patron/{{userId}}/edit_perms">{{username}}</a>.
+      </span>
+    </div>
+    <hr/>
+    <div class="mt-3">
+      <a routerLink="/staff/login" i18n>Sign In Again</a>
+    </div>
+  </div>
+</div>
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 (file)
index 0000000..32798c8
--- /dev/null
@@ -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());
+    }
+}
+
+
+
index b8d224c..225b931 100644 (file)
@@ -61,7 +61,7 @@ export class StaffResolver implements Resolve<Observable<any>> {
 
         // 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<Observable<any>> {
                         );
                     },
                     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');
                     }
                 );
             },
index d7981d7..e34324a 100644 (file)
@@ -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
   }, {
index 34bf589..ba3c6d6 100644 (file)
@@ -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: [