From 1607634d1768a36385fa3fb76b4c9c0c99fb595b Mon Sep 17 00:00:00 2001 From: Romain Verger Date: Thu, 3 Mar 2022 14:57:37 +0100 Subject: [PATCH 1/3] delete token expiration --- src/app/services/api-back.service.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/app/services/api-back.service.ts b/src/app/services/api-back.service.ts index e821706..cdeb5b0 100644 --- a/src/app/services/api-back.service.ts +++ b/src/app/services/api-back.service.ts @@ -59,12 +59,10 @@ export class ApiBackService { addRestaurant(newRestau: Restaurant): Observable { return this.httpClient.post(`${environment.apiUrl}/add-restaurant`, newRestau); - } deleteRestau(idRestau: number | undefined): Observable { return this.httpClient.delete(`${environment.apiUrl}/delete-restaurant/${idRestau}`); - } getPersonneById(id: any) { From daa51bafb13aa7c4b3366e408e18cbb4fe7782f4 Mon Sep 17 00:00:00 2001 From: Romain Verger Date: Thu, 3 Mar 2022 14:57:55 +0100 Subject: [PATCH 2/3] delete token expiration --- src/app/services/auth.guard.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/services/auth.guard.ts b/src/app/services/auth.guard.ts index 7ae6686..f16c965 100644 --- a/src/app/services/auth.guard.ts +++ b/src/app/services/auth.guard.ts @@ -3,13 +3,15 @@ import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTr import { Observable } from 'rxjs'; import { environment } from 'src/environments/environment'; import jwt_decode from 'jwt-decode'; +import { ApiBackService } from './api-back.service'; +import { TokenService } from './token.service'; @Injectable({ providedIn: 'root' }) export class AuthGuard implements CanActivate { private tokenKey: string; - constructor(private router: Router){ + constructor(private router: Router, private tokenService : TokenService){ this.tokenKey = environment.tokenKey; } @@ -29,6 +31,7 @@ export class AuthGuard implements CanActivate { const dateExp = new Date(decodedToken.exp * 1000); if(new Date() >= dateExp) { // le token a expiré, je n'autorise pas l'accès + this.tokenService.destroyToken(); this.router.navigate(['signin']); return false; } From 6de3e4dfdac07088b80a640f1c26eff6d66a76cb Mon Sep 17 00:00:00 2001 From: Romain Verger Date: Thu, 3 Mar 2022 17:16:07 +0100 Subject: [PATCH 3/3] Ajout prenom page d'accueil --- src/app/pages/home-page/home-page.component.html | 3 +-- src/app/pages/home-page/home-page.component.scss | 7 +++++++ src/app/pages/home-page/home-page.component.ts | 14 ++++++++++++-- src/app/pages/models/user.ts | 4 ++-- src/app/pages/resto-page/resto-page.component.ts | 1 - 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/app/pages/home-page/home-page.component.html b/src/app/pages/home-page/home-page.component.html index 68c67ae..aadcb86 100644 --- a/src/app/pages/home-page/home-page.component.html +++ b/src/app/pages/home-page/home-page.component.html @@ -1,2 +1 @@ -

Hello :D

- +

Hello {{userName}} !

diff --git a/src/app/pages/home-page/home-page.component.scss b/src/app/pages/home-page/home-page.component.scss index e69de29..bbc89ce 100644 --- a/src/app/pages/home-page/home-page.component.scss +++ b/src/app/pages/home-page/home-page.component.scss @@ -0,0 +1,7 @@ +#demotext { + color: #FFFFFF; + background: #912C22; + text-shadow: 0 0 10px #FFFFFF; + color: #FFFFFF; + background: #912C22; + } \ No newline at end of file diff --git a/src/app/pages/home-page/home-page.component.ts b/src/app/pages/home-page/home-page.component.ts index 95509ba..3cbf7bd 100644 --- a/src/app/pages/home-page/home-page.component.ts +++ b/src/app/pages/home-page/home-page.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { ApiBackService } from 'src/app/services/api-back.service'; +import { TokenService } from 'src/app/services/token.service'; @Component({ selector: 'app-home-page', @@ -8,15 +9,24 @@ import { ApiBackService } from 'src/app/services/api-back.service'; }) export class HomePageComponent implements OnInit { + public userName : any; - constructor(private apiBackService : ApiBackService) { + constructor(private apiBackService : ApiBackService, private tokenService : TokenService) { } ngOnInit(): void { + this.apiBackService.getPersonneById(this.tokenService.getCurrentUserId()).subscribe( + user =>{ + + this.userName = user.prenom; + + + + }) +} - } onEventLike(isLiked : boolean) { this.apiBackService.restoLiked$.next(isLiked); } diff --git a/src/app/pages/models/user.ts b/src/app/pages/models/user.ts index ca281f8..87c6596 100644 --- a/src/app/pages/models/user.ts +++ b/src/app/pages/models/user.ts @@ -1,6 +1,6 @@ -export interface User { +export interface User { id?:number; - firstName: string; + prenom: string; lastName: string; email: string; password?: string; diff --git a/src/app/pages/resto-page/resto-page.component.ts b/src/app/pages/resto-page/resto-page.component.ts index caf6e22..50aaee7 100644 --- a/src/app/pages/resto-page/resto-page.component.ts +++ b/src/app/pages/resto-page/resto-page.component.ts @@ -81,7 +81,6 @@ export class RestoPageComponent implements OnInit { if(listRestauIdLike.includes(restau.id)) - //console.log(restau); restau.restauLike = true; });