[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
|
||||
// ------------------------------------
|
||||
{ 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);
|
||||
|
@ -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;
|
||||
|
@ -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 { }
|
||||
|
@ -353,7 +353,6 @@ export class HttpWrapperService {
|
||||
|
||||
// Complex wrapper to simplify interaction:s
|
||||
putSpecific(urlPath: UrlPath, data: object):Promise<ModelResponseHttp> {
|
||||
console.log(`Put on ${urlPath}`);
|
||||
return new Promise((resolve, reject) => {
|
||||
this.request({
|
||||
endPoint: urlPath,
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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<void> {
|
||||
let locationOrigin = getApplicationLocation();
|
||||
let self = this;
|
||||
return new Promise<void>((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();
|
||||
|
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 { 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,
|
||||
}
|
||||
|
||||
|
@ -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'
|
||||
};
|
||||
|
||||
|
@ -51,7 +51,7 @@ const environment_hybrid = {
|
||||
ssoSignOut: 'http://192.168.1.156/karso/signout/karideo-dev/',
|
||||
frontBaseUrl: '',
|
||||
tokenStoredInPermanentStorage: false,
|
||||
apiMode: 'REWRITE'
|
||||
//apiMode: 'REWRITE'
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user