mis a
This commit is contained in:
parent
a204a18e99
commit
734a7f9068
@ -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),
|
||||
|
@ -28,7 +28,7 @@ export class SignupComponent implements OnInit {
|
||||
this.signupForm = new FormGroup({
|
||||
firstNameFc : new FormControl(''),
|
||||
lastNameFc : new FormControl(''),
|
||||
emailFc : new FormControl('', [Validators.email, Validators.required, Validators.pattern(/^([\w\.\-_]+)?\w+@[\w-_]+(\.\w+){1,}/igm)]), // chercher une meilleure regex
|
||||
emailFc : new FormControl('', [Validators.email, Validators.required, Validators.pattern("^([A-Z|a-z|0-9](\.|_){0,1})+[A-Z|a-z|0-9]\@([A-Z|a-z|0-9])+((\.){0,1}[A-Z|a-z|0-9]){2}\.[a-z]{2,3}$")]), // chercher une meilleure regex
|
||||
passwordFc : new FormControl('', [Validators.minLength(8), Validators.required]),
|
||||
roleFc : new FormControl('')
|
||||
})
|
||||
|
@ -25,11 +25,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);
|
||||
|
||||
if(decodedToken.exp) {
|
||||
@ -42,7 +37,13 @@ export class AuthGuard implements CanActivate {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(route.data['ROLE'] && route.data['ROLE'] != localStorage.getItem('ROLE')){
|
||||
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-not-found']);
|
||||
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