From 3a76a077b5343244dda932d668b02024b82b9ad2 Mon Sep 17 00:00:00 2001 From: Dan Funk Date: Tue, 26 May 2020 13:43:31 -0400 Subject: [PATCH] Allow this app to function under /bpmn url. Drop the login page all together, depend on the error interceptor to detect a logout, and redirect via shibboleth to the backend to get logged back in again. --- package-lock.json | 6 +++--- package.json | 2 +- src/app/app.module.ts | 19 ++++++++++++++++++- src/app/home/home.component.html | 3 +-- src/app/sign-in/sign-in.component.ts | 8 +------- src/app/sign-out/sign-out.component.ts | 5 +++-- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index b4388ff..91e7878 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12291,9 +12291,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sartography-workflow-lib": { - "version": "0.0.182", - "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.182.tgz", - "integrity": "sha512-iqhihrirlzgV+UyhHod0h37QKZSYBkRz1MGxN02cfBdY9b7SpaSG0zzErnwMTDFlWM2IsPiqi+wOx/d1FyFlRA==" + "version": "0.0.187", + "resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.187.tgz", + "integrity": "sha512-r2I+A1RMUyw6Rj04Wd8pOU5nmYZ9Rhk7ruljfcCWt6Trh/NxnNsjPNxrGWlHljA/JK5zMdTOgACeEFlLl+6y9Q==" }, "sass": { "version": "1.23.3", diff --git a/package.json b/package.json index dce604d..6a677c5 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "ngx-file-drop": "^8.0.8", "ngx-markdown": "^9.0.0", "rxjs": "~6.5.4", - "sartography-workflow-lib": "^0.0.182", + "sartography-workflow-lib": "0.0.187", "tslib": "^1.11.1", "uuid": "^7.0.2", "zone.js": "^0.10.3" diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 86a6ffc..c320af8 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,4 +1,4 @@ -import {APP_BASE_HREF} from '@angular/common'; +import {APP_BASE_HREF, PlatformLocation} from '@angular/common'; import {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http'; import {Injectable, NgModule} from '@angular/core'; import {FlexLayoutModule} from '@angular/flex-layout'; @@ -63,6 +63,21 @@ export class ThisEnvironment implements AppEnvironment { baseHref = environment.baseHref; } +/** + * This function is used internal to get a string instance of the `` value from `index.html`. + * This is an exported function, instead of a private function or inline lambda, to prevent this error: + * + * `Error encountered resolving symbol values statically.` + * `Function calls are not supported.` + * `Consider replacing the function or lambda with a reference to an exported function.` + * + * @param platformLocation an Angular service used to interact with a browser's URL + * @return a string instance of the `` value from `index.html` + */ +export function getBaseHref(platformLocation: PlatformLocation): string { + return platformLocation.getBaseHrefFromDOM(); +} + @NgModule({ declarations: [ AppComponent, @@ -133,6 +148,8 @@ export class ThisEnvironment implements AppEnvironment { // {provide: APP_BASE_HREF, useValue: environment.baseHref}, {provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true}, {provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptor, multi: true}, + {provide: APP_BASE_HREF, useFactory: getBaseHref, deps: [PlatformLocation] + } ] }) export class AppModule { diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index b9bf7b9..0d10643 100644 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -1,2 +1 @@ - - + diff --git a/src/app/sign-in/sign-in.component.ts b/src/app/sign-in/sign-in.component.ts index 1a59087..020e3de 100644 --- a/src/app/sign-in/sign-in.component.ts +++ b/src/app/sign-in/sign-in.component.ts @@ -70,13 +70,7 @@ export class SignInComponent implements OnInit { localStorage.removeItem('token'); // For testing purposes, create a user to simulate login. - if (!this.environment.production) { - localStorage.setItem('prev_url', location.origin); - this.model.redirect_url = location.origin + '/session'; - this.api.redirectToLogin(this.model.redirect_url, this.model); - } else { - this.error = new Error('This feature does not work in production.'); - } + this.api.redirectToLogin(); } // If this is production, verify the user and redirect to home page. diff --git a/src/app/sign-out/sign-out.component.ts b/src/app/sign-out/sign-out.component.ts index 8d1a929..ee8971b 100644 --- a/src/app/sign-out/sign-out.component.ts +++ b/src/app/sign-out/sign-out.component.ts @@ -1,5 +1,6 @@ import {Component, OnInit} from '@angular/core'; import {ApiService} from 'sartography-workflow-lib'; +import {Router} from '@angular/router'; @Component({ selector: 'app-sign-out', @@ -8,7 +9,7 @@ import {ApiService} from 'sartography-workflow-lib'; }) export class SignOutComponent implements OnInit { - constructor(private api: ApiService) { + constructor(private api: ApiService, private router: Router) { localStorage.removeItem('token'); } @@ -16,6 +17,6 @@ export class SignOutComponent implements OnInit { } goHome() { - this.api.openUrl('/'); + this.router.navigate(['/']); } }