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 { 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);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
export interface User {
|
||||
id?:number;
|
||||
firstName: string;
|
||||
prenom: string;
|
||||
lastName: string;
|
||||
email: string;
|
||||
password?: string;
|
||||
|
@ -85,7 +85,6 @@ export class RestoPageComponent implements OnInit {
|
||||
|
||||
|
||||
if(listRestauIdLike.includes(restau.id))
|
||||
|
||||
//console.log(restau);
|
||||
restau.restauLike = true;
|
||||
});
|
||||
|
@ -60,12 +60,10 @@ export class ApiBackService {
|
||||
|
||||
addRestaurant(newRestau: Restaurant): Observable<any> {
|
||||
return this.httpClient.post<any[]>(`${environment.apiUrl}/add-restaurant`, newRestau);
|
||||
|
||||
}
|
||||
|
||||
deleteRestau(idRestau: number | undefined): Observable<any> {
|
||||
return this.httpClient.delete<Restaurant>(`${environment.apiUrl}/delete-restaurant/${idRestau}`);
|
||||
|
||||
}
|
||||
|
||||
getPersonneById(id: any) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user