Merge branch 'dev' of https://github.com/RomainVgr/simpleat into dev
This commit is contained in:
commit
b7d5ef1043
@ -1,2 +1 @@
|
|||||||
<h1>Hello :D</h1>
|
<h1 style = "text-align: center;">Hello {{userName}} !</h1>
|
||||||
|
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
#demotext {
|
||||||
|
color: #FFFFFF;
|
||||||
|
background: #912C22;
|
||||||
|
text-shadow: 0 0 10px #FFFFFF;
|
||||||
|
color: #FFFFFF;
|
||||||
|
background: #912C22;
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ApiBackService } from 'src/app/services/api-back.service';
|
import { ApiBackService } from 'src/app/services/api-back.service';
|
||||||
|
import { TokenService } from 'src/app/services/token.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home-page',
|
selector: 'app-home-page',
|
||||||
@ -8,15 +9,24 @@ import { ApiBackService } from 'src/app/services/api-back.service';
|
|||||||
})
|
})
|
||||||
export class HomePageComponent implements OnInit {
|
export class HomePageComponent implements OnInit {
|
||||||
|
|
||||||
|
public userName : any;
|
||||||
|
|
||||||
constructor(private apiBackService : ApiBackService) {
|
constructor(private apiBackService : ApiBackService, private tokenService : TokenService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
|
this.apiBackService.getPersonneById(this.tokenService.getCurrentUserId()).subscribe(
|
||||||
|
user =>{
|
||||||
|
|
||||||
|
this.userName = user.prenom;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
onEventLike(isLiked : boolean) {
|
onEventLike(isLiked : boolean) {
|
||||||
this.apiBackService.restoLiked$.next(isLiked);
|
this.apiBackService.restoLiked$.next(isLiked);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export interface User {
|
export interface User {
|
||||||
id?:number;
|
id?:number;
|
||||||
firstName: string;
|
prenom: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
email: string;
|
email: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
|
@ -85,7 +85,6 @@ export class RestoPageComponent implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
if(listRestauIdLike.includes(restau.id))
|
if(listRestauIdLike.includes(restau.id))
|
||||||
|
|
||||||
//console.log(restau);
|
//console.log(restau);
|
||||||
restau.restauLike = true;
|
restau.restauLike = true;
|
||||||
});
|
});
|
||||||
|
@ -60,12 +60,10 @@ export class ApiBackService {
|
|||||||
|
|
||||||
addRestaurant(newRestau: Restaurant): Observable<any> {
|
addRestaurant(newRestau: Restaurant): Observable<any> {
|
||||||
return this.httpClient.post<any[]>(`${environment.apiUrl}/add-restaurant`, newRestau);
|
return this.httpClient.post<any[]>(`${environment.apiUrl}/add-restaurant`, newRestau);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteRestau(idRestau: number | undefined): Observable<any> {
|
deleteRestau(idRestau: number | undefined): Observable<any> {
|
||||||
return this.httpClient.delete<Restaurant>(`${environment.apiUrl}/delete-restaurant/${idRestau}`);
|
return this.httpClient.delete<Restaurant>(`${environment.apiUrl}/delete-restaurant/${idRestau}`);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getPersonneById(id: any) {
|
getPersonneById(id: any) {
|
||||||
|
@ -3,13 +3,15 @@ import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTr
|
|||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import jwt_decode from 'jwt-decode';
|
import jwt_decode from 'jwt-decode';
|
||||||
|
import { ApiBackService } from './api-back.service';
|
||||||
|
import { TokenService } from './token.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class AuthGuard implements CanActivate {
|
export class AuthGuard implements CanActivate {
|
||||||
private tokenKey: string;
|
private tokenKey: string;
|
||||||
constructor(private router: Router){
|
constructor(private router: Router, private tokenService : TokenService){
|
||||||
this.tokenKey = environment.tokenKey;
|
this.tokenKey = environment.tokenKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,6 +31,7 @@ export class AuthGuard implements CanActivate {
|
|||||||
const dateExp = new Date(decodedToken.exp * 1000);
|
const dateExp = new Date(decodedToken.exp * 1000);
|
||||||
if(new Date() >= dateExp) {
|
if(new Date() >= dateExp) {
|
||||||
// le token a expiré, je n'autorise pas l'accès
|
// le token a expiré, je n'autorise pas l'accès
|
||||||
|
this.tokenService.destroyToken();
|
||||||
this.router.navigate(['signin']);
|
this.router.navigate(['signin']);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user