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 3078cbc..40e8cfc 100644 --- a/src/app/pages/resto-page/resto-page.component.ts +++ b/src/app/pages/resto-page/resto-page.component.ts @@ -85,7 +85,6 @@ export class RestoPageComponent implements OnInit { if(listRestauIdLike.includes(restau.id)) - //console.log(restau); restau.restauLike = true; }); diff --git a/src/app/services/api-back.service.ts b/src/app/services/api-back.service.ts index 9f26101..7e37e82 100644 --- a/src/app/services/api-back.service.ts +++ b/src/app/services/api-back.service.ts @@ -60,12 +60,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) { 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; }