[DEBUG] correnct connection on retreive curent page and return sso page
This commit is contained in:
parent
6f96c0b929
commit
763dbed9c3
@ -35,6 +35,7 @@ const routes: Routes = [
|
|||||||
// -- SSO Generic interface
|
// -- SSO Generic interface
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
{ path: 'sso/:data/:keepConnected/:token', component: SsoScene },
|
{ path: 'sso/:data/:keepConnected/:token', component: SsoScene },
|
||||||
|
{ path: 'sso/:keepConnected/:token', component: SsoScene },
|
||||||
{ path: 'sso', component: SsoScene },
|
{ path: 'sso', component: SsoScene },
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
@ -97,8 +98,17 @@ const routes: Routes = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [ RouterModule.forRoot(routes) ],
|
imports: [
|
||||||
exports: [ RouterModule ]
|
RouterModule.forRoot(
|
||||||
|
routes,
|
||||||
|
{
|
||||||
|
//enableTracing: true, // <-- debugging purposes only
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
RouterModule,
|
||||||
|
]
|
||||||
})
|
})
|
||||||
export class AppRoutingModule { }
|
export class AppRoutingModule { }
|
||||||
// export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
|
// export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
|
||||||
|
@ -48,7 +48,7 @@ export class AppComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.location = location.pathname;
|
console.log(`>>>> APLLICATION INIT: BASE PATH: ${this.location}`);
|
||||||
this.autoConnectedDone = false;
|
this.autoConnectedDone = false;
|
||||||
this.isConnected = false;
|
this.isConnected = false;
|
||||||
this.updateMainMenu();
|
this.updateMainMenu();
|
||||||
@ -58,11 +58,6 @@ export class AppComponent implements OnInit {
|
|||||||
self.isConnected = isConnected;
|
self.isConnected = isConnected;
|
||||||
self.autoConnectedDone = true;
|
self.autoConnectedDone = true;
|
||||||
self.updateMainMenu();
|
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()
|
this.ssoService.checkSignUpEnable()
|
||||||
.then((value: boolean) => {
|
.then((value: boolean) => {
|
||||||
@ -76,7 +71,6 @@ export class AppComponent implements OnInit {
|
|||||||
this.userService.checkAutoConnect().then(() => {
|
this.userService.checkAutoConnect().then(() => {
|
||||||
console.log(` ==>>>>> Autoconnect THEN !!!`);
|
console.log(` ==>>>>> Autoconnect THEN !!!`);
|
||||||
self.autoConnectedDone = true;
|
self.autoConnectedDone = true;
|
||||||
//window.location.href = self.location;
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
console.log(` ==>>>>> Autoconnect CATCH !!!`);
|
console.log(` ==>>>>> Autoconnect CATCH !!!`);
|
||||||
self.autoConnectedDone = true;
|
self.autoConnectedDone = true;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
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 { RouterModule } from '@angular/router';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // this is needed for dynamic selection of the select
|
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: [
|
bootstrap: [
|
||||||
AppComponent
|
AppComponent
|
||||||
],
|
|
||||||
schemas: [
|
|
||||||
CUSTOM_ELEMENTS_SCHEMA,
|
|
||||||
NO_ERRORS_SCHEMA
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AppModule { }
|
export class AppModule { }
|
||||||
|
@ -353,7 +353,6 @@ export class HttpWrapperService {
|
|||||||
|
|
||||||
// Complex wrapper to simplify interaction:s
|
// Complex wrapper to simplify interaction:s
|
||||||
putSpecific(urlPath: UrlPath, data: object):Promise<ModelResponseHttp> {
|
putSpecific(urlPath: UrlPath, data: object):Promise<ModelResponseHttp> {
|
||||||
console.log(`Put on ${urlPath}`);
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.request({
|
this.request({
|
||||||
endPoint: urlPath,
|
endPoint: urlPath,
|
||||||
|
@ -136,7 +136,6 @@ export class OnlyUsersGuardHome implements CanActivate {
|
|||||||
private router: Router) {};
|
private router: Router) {};
|
||||||
|
|
||||||
canActivate() {
|
canActivate() {
|
||||||
console.log("OnlyLoggedInUsers");
|
|
||||||
if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin) ) {
|
if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin) ) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -166,7 +165,6 @@ export class OnlyAdminGuard implements CanActivate {
|
|||||||
private router: Router) {};
|
private router: Router) {};
|
||||||
|
|
||||||
canActivate() {
|
canActivate() {
|
||||||
console.log("OnlyLoggedInUsers");
|
|
||||||
if (this.sessionService.hasRight(UserRoles222.user)) {
|
if (this.sessionService.hasRight(UserRoles222.user)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { environment } from 'environments/environment';
|
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';
|
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from 'common/service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -33,22 +33,14 @@ export class SSOService {
|
|||||||
if (!isNullOrUndefined(data) && !isInArray(data, ["", "null", "NULL", "undefined", "---", "unregistered", "unregistered/", "forbidden", "forbidden/"])) {
|
if (!isNullOrUndefined(data) && !isInArray(data, ["", "null", "NULL", "undefined", "---", "unregistered", "unregistered/", "forbidden", "forbidden/"])) {
|
||||||
return this.utf8_to_b64(data);
|
return this.utf8_to_b64(data);
|
||||||
}
|
}
|
||||||
let pathName = window.location.pathname;
|
let pathName = getApplicationLocation();
|
||||||
console.log("start Path-name: '" + pathName + "'");
|
if (isInArray(pathName, ["sso", "/sso", "/sso/"])) {
|
||||||
console.log("check with: '" + environment.applName + "/sso/" + "'");
|
|
||||||
if (pathName.startsWith("/sso/") || pathName.startsWith(environment.applName + "/sso/")) {
|
|
||||||
return this.utf8_to_b64('home');
|
return this.utf8_to_b64('home');
|
||||||
}
|
}
|
||||||
if (pathName.startsWith('/' + environment.applName + '/')) {
|
if (!isNullOrUndefined(pathName) && !isInArray(pathName, ["", "null", "NULL", "undefined", "---", "unregistered", "unregistered/", "forbidden", "forbidden/"])) {
|
||||||
pathName = pathName.substring(environment.applName.length+2);
|
return this.utf8_to_b64(pathName);
|
||||||
} 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 this.utf8_to_b64(pathName);
|
return this.utf8_to_b64('home');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Request SSO connection
|
* Request SSO connection
|
||||||
|
@ -5,13 +5,15 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from './http-wrapper';
|
import { HTTPMimeType, HTTPRequestModel, HttpWrapperService, ModelResponseHttp } from './http-wrapper';
|
||||||
import { StorageService } from 'common/service/local-storage';
|
import { StorageService } from 'common/service/local-storage';
|
||||||
import { SessionService } from './session';
|
import { SessionService } from './session';
|
||||||
import { SSOService } from './sso';
|
import { SSOService } from './sso';
|
||||||
import { isNullOrUndefined } from 'common/utils';
|
import { getApplicationLocation, isNullOrUndefined } from 'common/utils';
|
||||||
|
|
||||||
interface MessageLogIn {
|
interface MessageLogIn {
|
||||||
login: string;
|
login: string;
|
||||||
@ -38,6 +40,7 @@ export class UserService {
|
|||||||
private cookiesToken = 'token';
|
private cookiesToken = 'token';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private router: Router,
|
||||||
private storageService: StorageService,
|
private storageService: StorageService,
|
||||||
private http: HttpWrapperService,
|
private http: HttpWrapperService,
|
||||||
private sessionService: SessionService,
|
private sessionService: SessionService,
|
||||||
@ -83,6 +86,7 @@ export class UserService {
|
|||||||
* Check if the system can be connected
|
* Check if the system can be connected
|
||||||
*/
|
*/
|
||||||
checkAutoConnect(): Promise<void> {
|
checkAutoConnect(): Promise<void> {
|
||||||
|
let locationOrigin = getApplicationLocation();
|
||||||
let self = this;
|
let self = this;
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
// Need to use the windows global route to prevent the log in cycle ...
|
// 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.removeSession(this.cookiesToken);
|
||||||
this.storageService.remove(this.cookiesToken);
|
this.storageService.remove(this.cookiesToken);
|
||||||
self.startSession(token, rememberMe).then(() => {
|
self.startSession(token, rememberMe).then(() => {
|
||||||
|
self.router.navigateByUrl(locationOrigin);
|
||||||
|
console.log(`update global URL = ${locationOrigin}`);
|
||||||
resolve();
|
resolve();
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// jump in the sign-in page (automatically of request remember-me)
|
// 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.cookiesRememberMe);
|
||||||
this.storageService.remove(this.cookiesToken);
|
this.storageService.remove(this.cookiesToken);
|
||||||
this.storageService.removeSession(this.cookiesToken);
|
this.storageService.removeSession(this.cookiesToken);
|
||||||
self.ssoService.requestSignIn();
|
self.ssoService.requestSignIn(locationOrigin);
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
@ -130,7 +136,7 @@ export class UserService {
|
|||||||
this.storageService.remove(this.cookiesRememberMe);
|
this.storageService.remove(this.cookiesRememberMe);
|
||||||
this.storageService.remove(this.cookiesToken);
|
this.storageService.remove(this.cookiesToken);
|
||||||
this.storageService.removeSession(this.cookiesToken);
|
this.storageService.removeSession(this.cookiesToken);
|
||||||
self.ssoService.requestSignIn();
|
self.ssoService.requestSignIn(locationOrigin);
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
|
17
front/src/common/utils/applPath.ts
Normal file
17
front/src/common/utils/applPath.ts
Normal file
@ -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;
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
import { getApplicationLocation } from "./applPath";
|
||||||
import { DataInterface, TypeCheck } from "./dataInterface";
|
import { DataInterface, TypeCheck } from "./dataInterface";
|
||||||
import { isArray, isArrayOf, isBoolean, isNull, isNullOrUndefined, isNumber, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString, isUndefined, isArrayOfs, isInArray, isStringNullOrUndefined } from "./validator";
|
import { isArray, isArrayOf, isBoolean, isNull, isNullOrUndefined, isNumber, isNumberFinite, isObject, isOptionalOf, isOptionalArrayOf, isString, isUndefined, isArrayOfs, isInArray, isStringNullOrUndefined } from "./validator";
|
||||||
|
|
||||||
@ -21,5 +22,6 @@ export {
|
|||||||
isStringNullOrUndefined,
|
isStringNullOrUndefined,
|
||||||
DataInterface,
|
DataInterface,
|
||||||
TypeCheck,
|
TypeCheck,
|
||||||
|
getApplicationLocation,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
// The list of which env maps to which file can be found in `.angular-cli.json`.
|
||||||
|
|
||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: true,
|
||||||
// URL of development API
|
// URL of development API
|
||||||
applName: "karideo",
|
applName: "karideo",
|
||||||
defaultServer: "karideo",
|
defaultServer: "karideo",
|
||||||
@ -17,6 +17,6 @@ export const environment = {
|
|||||||
ssoSignOut: `${location.origin}/karso/signout/karideo/`,
|
ssoSignOut: `${location.origin}/karso/signout/karideo/`,
|
||||||
frontBaseUrl: '',
|
frontBaseUrl: '',
|
||||||
tokenStoredInPermanentStorage: false,
|
tokenStoredInPermanentStorage: false,
|
||||||
apiMode: 'REWRITE'
|
//apiMode: 'REWRITE'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ const environment_hybrid = {
|
|||||||
ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/',
|
ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/',
|
||||||
frontBaseUrl: '',
|
frontBaseUrl: '',
|
||||||
tokenStoredInPermanentStorage: false,
|
tokenStoredInPermanentStorage: false,
|
||||||
apiMode: 'REWRITE'
|
//apiMode: 'REWRITE'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user