From 97242643b9bbc778d78b2ff56c63bbab7bba8655 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sat, 6 Apr 2024 13:07:46 +0200 Subject: [PATCH] [DEV] update to basic work --- src/component/top-menu/top-menu.ts | 2 +- src/kar-cw.component.ts | 3 +-- src/kar-cw.module.ts | 6 +++--- src/service/session.ts | 23 ++++++++++++++++------- src/service/user.ts | 24 +++++------------------- 5 files changed, 26 insertions(+), 32 deletions(-) diff --git a/src/component/top-menu/top-menu.ts b/src/component/top-menu/top-menu.ts index 0580fb2..995b302 100644 --- a/src/component/top-menu/top-menu.ts +++ b/src/component/top-menu/top-menu.ts @@ -16,7 +16,7 @@ export interface EventOnMenu { } @Component({ - selector: 'app-top-menu', + selector: 'karcw-top-menu', templateUrl: './top-menu.html', styleUrls: ['./top-menu.less'], }) diff --git a/src/kar-cw.component.ts b/src/kar-cw.component.ts index 65b0f92..236916b 100644 --- a/src/kar-cw.component.ts +++ b/src/kar-cw.component.ts @@ -2,11 +2,10 @@ import { PopInComponent, TopMenuComponent, UploadFileComponent, ErrorComponent, import { PopInUploadProgress, PopInDeleteConfirm } from './popin'; export const ALL_COMPONENTS = [ + TopMenuComponent, PopInComponent, PopInUploadProgress, PopInDeleteConfirm, - - TopMenuComponent, UploadFileComponent, ErrorComponent, PasswordEntryComponent, diff --git a/src/kar-cw.module.ts b/src/kar-cw.module.ts index 9ef3ad4..3d43336 100644 --- a/src/kar-cw.module.ts +++ b/src/kar-cw.module.ts @@ -15,7 +15,7 @@ import { ALL_GUARDS } from "./kar-cw.guard"; @NgModule({ declarations: [ ...ALL_COMPONENTS, - ...ALL_SCENES, + //...ALL_SCENES, ], imports: [ CommonModule, @@ -28,10 +28,10 @@ import { ALL_GUARDS } from "./kar-cw.guard"; ], exports: [ ...ALL_COMPONENTS, - ...ALL_SCENES, + //...ALL_SCENES, //...ALL_SERVICES, //...ALL_GUARDS, ], - //schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], + schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], }) export class KarCWModule { } diff --git a/src/service/session.ts b/src/service/session.ts index 33f3f3b..a8435c5 100644 --- a/src/service/session.ts +++ b/src/service/session.ts @@ -130,9 +130,10 @@ export class SessionService { providedIn: 'root', }) export class OnlyUsersGuard { - constructor(private sessionService: SessionService, private router: Router) { } + constructor(/*private sessionService: SessionService, */private router: Router) { } canActivate() { + /* console.log('OnlyLoggedInUsers'); if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin)) { return true; @@ -140,6 +141,8 @@ export class OnlyUsersGuard { this.router.navigateByUrl('/forbidden'); return false; } + */ + return true; } } @@ -147,44 +150,50 @@ export class OnlyUsersGuard { providedIn: 'root', }) export class OnlyUsersGuardHome { - constructor(private sessionService: SessionService, private router: Router) { } + constructor(/*private sessionService: SessionService, */private router: Router) { } - canActivate() { + canActivate() {/* if (this.sessionService.hasRight(UserRoles222.user) || this.sessionService.hasRight(UserRoles222.admin)) { return true; } else { this.router.navigateByUrl('/unregistered'); return false; } + */ + return true; } } @Injectable({ providedIn: 'root', }) export class OnlyUnregisteredGuardHome { - constructor(private sessionService: SessionService, private router: Router) { } + constructor(/*private sessionService: SessionService, */private router: Router) { } - canActivate() { + canActivate() {/* if (!this.sessionService.islogged()) { return true; } else { this.router.navigateByUrl('/home'); return false; } + */ + return true; } } @Injectable({ providedIn: 'root', }) export class OnlyAdminGuard { - constructor(private sessionService: SessionService, private router: Router) { } + constructor(/*private sessionService: SessionService, */private router: Router) { } - canActivate() { + canActivate() {/* if (this.sessionService.hasRight(UserRoles222.user)) { return true; } else { this.router.navigateByUrl('/forbidden'); return false; } + */ + return true; } } diff --git a/src/service/user.ts b/src/service/user.ts index f2afda4..82d104b 100644 --- a/src/service/user.ts +++ b/src/service/user.ts @@ -14,21 +14,7 @@ import { getApplicationLocation, isNullOrUndefined, sha512 } from '../utils'; import { HttpWrapperService, HTTPRequestModel, HTTPMimeType, ModelResponseHttp } from './http-wrapper_kjdhqslkjf'; import { EnvironmentService } from '../model/environment'; -/* -interface MessageLogIn { - login: string; - method: string; - time: number; - password: string; -} -interface MessageAnswer_USER_CONNECT { - sessionId: string; - login: string; - eMail: string; - role: string; - avatar: string; -} -*/ + @Injectable({ providedIn: 'root', }) @@ -73,14 +59,14 @@ export class UserService { } // const tokenHeader = decodeURIComponent(window.atob( elems[0] )); const tokenData = decodeURIComponent(window.atob(elems[1])); - // console.error(`Retreive local token: \nheader=${tokenHeader} \ndata=${tokenData}`); + // console.error(`Retrieve local token: \nheader=${tokenHeader} \ndata=${tokenData}`); const parsedData = JSON.parse(tokenData); console.debug( - `Retreive token exp data=${new Date(parsedData.exp * 1000).toISOString()} < ${new Date().toISOString()}` + `Retrieve token exp data=${new Date(parsedData.exp * 1000).toISOString()} < ${new Date().toISOString()}` ); const expireIn = new Date(parsedData.exp * 1000); const nowTime = new Date(); - // TODO: set a marging of 2 hours... + // TODO: set a margin of 2 hours... return expireIn > nowTime; } @@ -96,7 +82,7 @@ export class UserService { const self = this; return new Promise((resolve, reject) => { // Need to use the windows global route to prevent the log in cycle ... - // And in the mlain application position, the route does not have curently root the page + // And in the main application position, the route does not have currently root the page let pathName = window.location.pathname; // console.log("start Path-name: '" + pathName + "'"); // console.log("check with: '" + environment.applName + "/sso/" + "'");