From ecb422e18b66171090ba5a3d8a8c6c4709c7d035 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 7 Apr 2024 09:06:05 +0200 Subject: [PATCH] [DEV] still work --- src/kar-cw.module.ts | 2 +- src/service/session.ts | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/kar-cw.module.ts b/src/kar-cw.module.ts index fb45f88..dee3db8 100644 --- a/src/kar-cw.module.ts +++ b/src/kar-cw.module.ts @@ -23,7 +23,7 @@ import { ALL_GUARDS } from "./kar-cw.guard"; ReactiveFormsModule, ], providers: [ - //...ALL_SERVICES, + ...ALL_SERVICES, ...ALL_GUARDS, ], exports: [ diff --git a/src/service/session.ts b/src/service/session.ts index a8435c5..f64d46a 100644 --- a/src/service/session.ts +++ b/src/service/session.ts @@ -130,10 +130,9 @@ 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; @@ -141,7 +140,6 @@ export class OnlyUsersGuard { this.router.navigateByUrl('/forbidden'); return false; } - */ return true; } } @@ -150,16 +148,15 @@ 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; } } @@ -167,16 +164,15 @@ export class OnlyUsersGuardHome { 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; } } @@ -184,16 +180,15 @@ export class OnlyUnregisteredGuardHome { 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; } }