diff --git a/front/src/app/app-routing.module.ts b/front/src/app/app-routing.module.ts index c9eaaba..e2aaeef 100644 --- a/front/src/app/app-routing.module.ts +++ b/front/src/app/app-routing.module.ts @@ -35,6 +35,7 @@ const routes: Routes = [ // -- SSO Generic interface // ------------------------------------ { path: 'sso/:data/:keepConnected/:token', component: SsoScene }, + { path: 'sso/:keepConnected/:token', component: SsoScene }, { path: 'sso', component: SsoScene }, // ------------------------------------ @@ -97,8 +98,17 @@ const routes: Routes = [ ]; @NgModule({ - imports: [ RouterModule.forRoot(routes) ], - exports: [ RouterModule ] + imports: [ + RouterModule.forRoot( + routes, + { + //enableTracing: true, // <-- debugging purposes only + }, + ), + ], + exports: [ + RouterModule, + ] }) export class AppRoutingModule { } // export const routing: ModuleWithProviders = RouterModule.forRoot(routes); diff --git a/front/src/app/app.component.ts b/front/src/app/app.component.ts index 08feba7..fa7becb 100644 --- a/front/src/app/app.component.ts +++ b/front/src/app/app.component.ts @@ -48,7 +48,7 @@ export class AppComponent implements OnInit { } ngOnInit() { - this.location = location.pathname; + console.log(`>>>> APLLICATION INIT: BASE PATH: ${this.location}`); this.autoConnectedDone = false; this.isConnected = false; this.updateMainMenu(); @@ -58,11 +58,6 @@ export class AppComponent implements OnInit { self.isConnected = isConnected; self.autoConnectedDone = true; self.updateMainMenu(); - if (isConnected) { - console.log("Is connected then back to the requested page") - self.router.navigateByUrl(self.location); - console.log(`update global URL = ${self.location}`); - } }); this.ssoService.checkSignUpEnable() .then((value: boolean) => { @@ -76,7 +71,6 @@ export class AppComponent implements OnInit { this.userService.checkAutoConnect().then(() => { console.log(` ==>>>>> Autoconnect THEN !!!`); self.autoConnectedDone = true; - //window.location.href = self.location; }).catch(() => { console.log(` ==>>>>> Autoconnect CATCH !!!`); self.autoConnectedDone = true; diff --git a/front/src/app/app.module.ts b/front/src/app/app.module.ts index 286344c..b5f89f5 100644 --- a/front/src/app/app.module.ts +++ b/front/src/app/app.module.ts @@ -5,7 +5,7 @@ */ import { BrowserModule } from '@angular/platform-browser'; -import { NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core'; +import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { HttpClientModule } from '@angular/common/http'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // this is needed for dynamic selection of the select @@ -111,10 +111,6 @@ import { ErrorComponent, TopMenuComponent } from 'common/component'; ], bootstrap: [ AppComponent - ], - schemas: [ - CUSTOM_ELEMENTS_SCHEMA, - NO_ERRORS_SCHEMA ] }) export class AppModule { } diff --git a/front/src/common/service/http-wrapper.ts b/front/src/common/service/http-wrapper.ts index 54b18ab..d951d82 100644 --- a/front/src/common/service/http-wrapper.ts +++ b/front/src/common/service/http-wrapper.ts @@ -353,7 +353,6 @@ export class HttpWrapperService { // Complex wrapper to simplify interaction:s putSpecific(urlPath: UrlPath, data: object):Promise { - console.log(`Put on ${urlPath}`); return new Promise((resolve, reject) => { this.request({ endPoint: urlPath, diff --git a/front/src/common/service/session.ts b/front/src/common/service/session.ts index 4161f4c..b4fc551 100644 --- a/front/src/common/service/session.ts +++ b/front/src/common/service/session.ts @@ -136,7 +136,6 @@ export class OnlyUsersGuardHome implements CanActivate { private router: Router) {}; canActivate() { - console.log("OnlyLoggedInUsers"); if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin) ) { return true; } else { @@ -166,7 +165,6 @@ export class OnlyAdminGuard implements CanActivate { private router: Router) {}; canActivate() { - console.log("OnlyLoggedInUsers"); if (this.sessionService.hasRight(UserRoles222.user)) { return true; } else { diff --git a/front/src/common/service/sso.ts b/front/src/common/service/sso.ts index 2899059..49b52cf 100644 --- a/front/src/common/service/sso.ts +++ b/front/src/common/service/sso.ts @@ -6,7 +6,7 @@ import { Injectable } from '@angular/core'; import { environment } from 'environments/environment'; -import { isInArray, isNullOrUndefined } from 'common/utils'; +import { getApplicationLocation, isInArray, isNullOrUndefined } from 'common/utils'; import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from 'common/service'; @Injectable() @@ -33,22 +33,14 @@ export class SSOService { if (!isNullOrUndefined(data) && !isInArray(data, ["", "null", "NULL", "undefined", "---", "unregistered", "unregistered/", "forbidden", "forbidden/"])) { return this.utf8_to_b64(data); } - let pathName = window.location.pathname; - console.log("start Path-name: '" + pathName + "'"); - console.log("check with: '" + environment.applName + "/sso/" + "'"); - if (pathName.startsWith("/sso/") || pathName.startsWith(environment.applName + "/sso/")) { + let pathName = getApplicationLocation(); + if (isInArray(pathName, ["sso", "/sso", "/sso/"])) { return this.utf8_to_b64('home'); } - if (pathName.startsWith('/' + environment.applName + '/')) { - pathName = pathName.substring(environment.applName.length+2); - } else if (pathName.startsWith('/' + environment.applName)) { - pathName = pathName.substring(environment.applName.length + 1); - } else if (pathName.startsWith(environment.applName + '/')) { - pathName = pathName.substring(environment.applName.length+1); - } else if (pathName.startsWith(environment.applName)) { - pathName = pathName.substring(environment.applName.length); + if (!isNullOrUndefined(pathName) && !isInArray(pathName, ["", "null", "NULL", "undefined", "---", "unregistered", "unregistered/", "forbidden", "forbidden/"])) { + return this.utf8_to_b64(pathName); } - return this.utf8_to_b64(pathName); + return this.utf8_to_b64('home'); } /** * Request SSO connection diff --git a/front/src/common/service/user.ts b/front/src/common/service/user.ts index 0f8067e..7e800fa 100644 --- a/front/src/common/service/user.ts +++ b/front/src/common/service/user.ts @@ -5,13 +5,15 @@ */ import { Injectable } from '@angular/core'; +import { Router } from '@angular/router'; + import { environment } from 'environments/environment'; import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from './http-wrapper'; import { StorageService } from 'common/service/local-storage'; import { SessionService } from './session'; import { SSOService } from './sso'; -import { isNullOrUndefined } from 'common/utils'; +import { getApplicationLocation, isNullOrUndefined } from 'common/utils'; interface MessageLogIn { login: string; @@ -38,6 +40,7 @@ export class UserService { private cookiesToken = 'token'; constructor( + private router: Router, private storageService: StorageService, private http: HttpWrapperService, private sessionService: SessionService, @@ -83,6 +86,7 @@ export class UserService { * Check if the system can be connected */ checkAutoConnect(): Promise { + let locationOrigin = getApplicationLocation(); let self = this; return new Promise((resolve, reject) => { // Need to use the windows global route to prevent the log in cycle ... @@ -110,6 +114,8 @@ export class UserService { this.storageService.removeSession(this.cookiesToken); this.storageService.remove(this.cookiesToken); self.startSession(token, rememberMe).then(() => { + self.router.navigateByUrl(locationOrigin); + console.log(`update global URL = ${locationOrigin}`); resolve(); }).catch(() => { // jump in the sign-in page (automatically of request remember-me) @@ -118,7 +124,7 @@ export class UserService { this.storageService.remove(this.cookiesRememberMe); this.storageService.remove(this.cookiesToken); this.storageService.removeSession(this.cookiesToken); - self.ssoService.requestSignIn(); + self.ssoService.requestSignIn(locationOrigin); reject(); } resolve(); @@ -130,7 +136,7 @@ export class UserService { this.storageService.remove(this.cookiesRememberMe); this.storageService.remove(this.cookiesToken); this.storageService.removeSession(this.cookiesToken); - self.ssoService.requestSignIn(); + self.ssoService.requestSignIn(locationOrigin); reject(); } resolve(); diff --git a/front/src/common/utils/applPath.ts b/front/src/common/utils/applPath.ts new file mode 100644 index 0000000..5109ec1 --- /dev/null +++ b/front/src/common/utils/applPath.ts @@ -0,0 +1,17 @@ +import { environment } from "environments/environment"; + +export function getApplicationLocation(): string { + let pathName = location.pathname; + //console.log("start Path-name: '" + pathName + "'"); + //console.log("check with: '" + environment.applName + "/sso/" + "'"); + if (pathName.startsWith('/' + environment.applName + '/')) { + pathName = pathName.substring(environment.applName.length+2); + } else if (pathName.startsWith('/' + environment.applName)) { + pathName = pathName.substring(environment.applName.length + 1); + } else if (pathName.startsWith(environment.applName + '/')) { + pathName = pathName.substring(environment.applName.length+1); + } else if (pathName.startsWith(environment.applName)) { + pathName = pathName.substring(environment.applName.length); + } + return pathName; +} \ No newline at end of file diff --git a/front/src/common/utils/index.ts b/front/src/common/utils/index.ts index 286cecf..eab7a9c 100644 --- a/front/src/common/utils/index.ts +++ b/front/src/common/utils/index.ts @@ -1,5 +1,6 @@ +import { getApplicationLocation } from "./applPath"; import { DataInterface, TypeCheck } from "./dataInterface"; import { isArray, isArrayOf, isBoolean, isNull, isNullOrUndefined, isNumber, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString, isUndefined, isArrayOfs, isInArray, isStringNullOrUndefined } from "./validator"; @@ -21,5 +22,6 @@ export { isStringNullOrUndefined, DataInterface, TypeCheck, + getApplicationLocation, } diff --git a/front/src/environments/environment.prod.ts b/front/src/environments/environment.prod.ts index 44c6b47..645c339 100644 --- a/front/src/environments/environment.prod.ts +++ b/front/src/environments/environment.prod.ts @@ -4,7 +4,7 @@ // The list of which env maps to which file can be found in `.angular-cli.json`. export const environment = { - production: false, + production: true, // URL of development API applName: "karideo", defaultServer: "karideo", @@ -17,6 +17,6 @@ export const environment = { ssoSignOut: `${location.origin}/karso/signout/karideo/`, frontBaseUrl: '', tokenStoredInPermanentStorage: false, - apiMode: 'REWRITE' + //apiMode: 'REWRITE' }; diff --git a/front/src/environments/environment.ts b/front/src/environments/environment.ts index 56a4787..1993ae2 100644 --- a/front/src/environments/environment.ts +++ b/front/src/environments/environment.ts @@ -51,7 +51,7 @@ const environment_hybrid = { ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/', frontBaseUrl: '', tokenStoredInPermanentStorage: false, - apiMode: 'REWRITE' + //apiMode: 'REWRITE' };