KON-703 Keine Authentifizierung - Logout/Portal Page
diff --git a/.gitignore b/.gitignore
index 4f5768b..eb42148 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,7 +8,7 @@
/node_modules
# IDEs and editors
-/.idea
+.idea
/.vscode
.project
.classpath
diff --git a/config/development.json b/config/development.json
index 0c961ef..0fa0435 100644
--- a/config/development.json
+++ b/config/development.json
@@ -5,7 +5,8 @@
"paths": {
"imagesRoot": "/assets/images/",
- "userImageFolder": "/assets/images/users/"
+ "userImageFolder": "/assets/images/users/",
+ "portalLoginUrl": "http://entopkon:8880/portalFE/#/login"
},
"localization": {
diff --git a/config/local.json b/config/local.json
new file mode 100644
index 0000000..fe125bb
--- /dev/null
+++ b/config/local.json
@@ -0,0 +1,33 @@
+{
+ "api": {
+ "baseUrl": "/api"
+ },
+
+ "paths": {
+ "imagesRoot": "/assets/images/",
+ "userImageFolder": "/assets/images/users/",
+ "portalLoginUrl": "http://localhost:8080/portalFE/#/login"
+ },
+
+ "localization": {
+ "languages": [
+ {"code": "de", "name": "DE", "culture": "de-DE"},
+ {"code": "en", "name": "EN", "culture": "en-EN"}
+ ],
+ "defaultLanguage": "de"
+ },
+
+ "notifications": {
+ "options": {
+ "timeOut": 5000,
+ "showProgressBar": true,
+ "pauseOnHover": true,
+ "position": ["top", "right"],
+ "theClass": "sy-notification"
+ },
+ "unauthorizedEndpoints": [],
+ "notFoundEndpoints": []
+ },
+
+ "debugging": true
+}
diff --git a/config/production.json b/config/production.json
index 0ef2a1f..fa74315 100644
--- a/config/production.json
+++ b/config/production.json
@@ -5,7 +5,8 @@
"paths": {
"imagesRoot": "/assets/images/",
- "userImageFolder": "/assets/images/users/"
+ "userImageFolder": "/assets/images/users/",
+ "portalLoginUrl": "http://169.50.13.154/portalFE/#/login"
},
"localization": {
diff --git a/hooks/pre-local.js b/hooks/pre-local.js
new file mode 100644
index 0000000..4ffb72d
--- /dev/null
+++ b/hooks/pre-local.js
@@ -0,0 +1,46 @@
+/********************************************************************************
+ * Copyright (c) 2020 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ ********************************************************************************/
+var fs = require('fs-extra');
+var jsonConcat = require('json-concat');
+
+var localizationSourceFilesDE = [
+ "./i18n/general.de.json",
+ "./i18n/components.de.json",
+ "./i18n/contacts.de.json",
+ "./i18n/persons.de.json",
+ "./i18n/salutations.de.json",
+ "./i18n/company.de.json",
+ "./i18n/admin.de.json",
+ "./i18n/addresses.de.json",
+ "./i18n/communications-data.de.json",
+ "./i18n/user-module-assignment.de.json",
+ "./i18n/logout.de.json",
+];
+
+function mergeAndSaveJsonFiles(src, dest) {
+ jsonConcat({ src: src, dest: dest }, function(res) {
+ console.log('Localization files successfully merged!');
+ });
+}
+
+function setEnvironment(configPath, environment) {
+ fs.writeJson(configPath, { env: environment }, function(res) {
+ console.log('Environment variable set to ' + environment);
+ });
+}
+
+// Set environment variable to "local env"
+setEnvironment('./config/env.json', 'local');
+
+// Merge all localization files into one
+mergeAndSaveJsonFiles(localizationSourceFilesDE, './i18n/de.json');
diff --git a/package.json b/package.json
index 82c914b..654d20b 100644
--- a/package.json
+++ b/package.json
@@ -8,13 +8,14 @@
"scripts": {
"start": "npm run sy-pre-start && ng serve --proxy-config proxy.conf.json",
"start-integration": "npm run sy-pre-start && ng serve --proxy-config proxy.conf-integration.json",
- "start-local": "npm run sy-pre-start && ng serve --proxy-config proxy.conf-local.json",
+ "start-local": "npm run sy-pre-local && ng serve --proxy-config proxy.conf-local.json",
"test": "npm run sy-pre-test && ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "ng e2e",
"build": "npm run sy-pre-build && ng build --base-href /contactdatabase/ && npm run sy-post-build",
"sy-pre-test": "node hooks/pre-test.js",
"sy-pre-start": "node hooks/pre-start.js",
+ "sy-pre-local": "node hooks/pre-local.js",
"sy-pre-build": "node hooks/pre-build.js",
"sy-post-build": "node hooks/post-build.js",
"sy-build": "npm run sy-pre-build && ng build --base-href /contactdatabase/ --prod --aot && npm run sy-post-build",
diff --git a/src/app/shared/asyncServices/http/httpResponseHandler.service.ts b/src/app/shared/asyncServices/http/httpResponseHandler.service.ts
index de77226..4a3e527 100644
--- a/src/app/shared/asyncServices/http/httpResponseHandler.service.ts
+++ b/src/app/shared/asyncServices/http/httpResponseHandler.service.ts
@@ -16,6 +16,9 @@
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { ConfigService } from 'app/app-config.service';
+import { Store } from '@ngrx/store';
+import * as store from '@shared/store';
+import * as settingsActions from '@shared/store/actions/settings.action';
@Injectable()
export class HttpResponseHandler {
@@ -23,7 +26,8 @@
private router: Router,
private translateService: TranslateService,
private notificationsService: NotificationsService,
- private configService: ConfigService
+ private configService: ConfigService,
+ protected appState$: Store<store.State>
) {}
/**
@@ -95,9 +99,17 @@
private handleUnauthorized(responseBody: any): void {
// Read configuration in order to see if we need to display 401 notification message
let unauthorizedEndpoints: Array<string> = this.configService.get('notifications').unauthorizedEndpoints;
+ let portalLoginUrl: string = this.configService.get('paths').portalLoginUrl;
unauthorizedEndpoints = unauthorizedEndpoints.filter(endpoint => this.getRelativeUrl(responseBody.url) === endpoint);
- this.router.navigate(['/loggedout']);
+ localStorage.clear();
+ if (portalLoginUrl) {
+ this.appState$.dispatch(settingsActions.setUser(null));
+ window.location.href= portalLoginUrl;
+ } else {
+ this.appState$.dispatch(settingsActions.setUser(null));
+ this.router.navigate(['/loggedout']);
+ }
if (unauthorizedEndpoints.length) {
this.notificationsService.info('Info', this.translateService.instant('ServerError401'), this.configService.get('notifications').options);
diff --git a/src/app/shared/components/header/header.component.html b/src/app/shared/components/header/header.component.html
index d590b12..7bbba7e 100644
--- a/src/app/shared/components/header/header.component.html
+++ b/src/app/shared/components/header/header.component.html
@@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/ -->
-<nav class="navbar navbar-default navbar-fixed-top masthead overview-navbar" role="banner">
+<nav *ngIf="userName" class="navbar navbar-default navbar-fixed-top masthead overview-navbar" role="banner">
<div class="container-fluid">
<div class="navbar-header" (click)="navigateToOverview()">
<a class="navbar-brand">