merge resolution
This commit is contained in:
commit
65ab8cf9bc
@ -72,7 +72,7 @@ export class AddRestauComponent implements OnInit {
|
||||
latitudeFc: new FormControl(restau.latitude, [Validators.required]),
|
||||
adresseFc: new FormControl(restau.adresse, [Validators.required]),
|
||||
telephoneFc: new FormControl(restau.telephone),
|
||||
websiteFc: new FormControl(restau.website, [Validators.pattern("/^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/")]),
|
||||
websiteFc: new FormControl(restau.website, [Validators.pattern("/^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/")]), // voir une autre regex
|
||||
surPlaceFc: new FormControl(restau.surPlace),
|
||||
aEmporterFc: new FormControl(restau.aEmporter),
|
||||
accesPMRFc: new FormControl(restau.accesPMR),
|
||||
|
@ -24,11 +24,6 @@ export class AuthGuard implements CanActivate {
|
||||
|
||||
if(token) {
|
||||
const decodedToken = jwt_decode<any>(token);
|
||||
|
||||
// TODO boucle sur le ['auth'] pour controler le role et en fonction de ca renvoyer true ou false ac redirection page403
|
||||
//console.log(decodedToken['auth'][0]['authority']);
|
||||
|
||||
|
||||
|
||||
console.log('decodedToken : ', decodedToken);
|
||||
|
||||
@ -42,8 +37,14 @@ export class AuthGuard implements CanActivate {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(route.data['ROLE'] && route.data['ROLE'] != localStorage.getItem('ROLE')){
|
||||
this.router.navigate(['page-denied']);
|
||||
if(route.data['ROLE'] ){
|
||||
for (let index = 0; index < decodedToken['auth'].length; index++) {
|
||||
if(route.data['ROLE'] == decodedToken['auth'][index]['authority']){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
this.router.navigate(['page-denied']);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -36,12 +36,9 @@ export class AuthService {
|
||||
map((x: any) => {
|
||||
//console.log(x);
|
||||
|
||||
const decodedToken = jwt_decode<any>(x.token);
|
||||
//console.log('Service : ', x.token);
|
||||
// Modification à faire ici
|
||||
localStorage.setItem(this.tokenKey, x.token);
|
||||
|
||||
localStorage.setItem('ROLE', decodedToken['auth'][0]['authority']);
|
||||
return x; // permet de renvoyer la réponse à l'initiateur (page Signin) après le traitement du map
|
||||
})
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user