Merge remote-tracking branch 'origin/main'

This commit is contained in:
tuanvu
2026-01-09 13:39:02 +01:00
3 changed files with 22 additions and 21 deletions

View File

@@ -105,7 +105,7 @@ export class Coach extends User{
id_keycloak: this.keycloakId,
name: this.nom,
prenom: this.prenom,
sessionIds: this.sessionsID,
sessionIds: this.sessionsID ,
};
return dto;
}

View File

@@ -22,32 +22,32 @@ export async function loginOrRegister(keycloak:Keycloak): Promise<User|null>{
const roles = keycloak.tokenParsed?.realm_access?.roles
if(roles!=null){
if(roles.includes("admin")){
const id = keycloak.tokenParsed?.sub;
if(id!=null){
const response = await athleteService.getByKeycloakId(id);
const admin = new Admin(response.data);
return admin;
}
const id = keycloak.tokenParsed?.sub;
if(id!=null){
const response = await athleteService.create(id);
const admin = new Admin(response.data);
return admin;
}
}
else if(roles.includes("coach")){
const id = keycloak.tokenParsed?.sub;
if(id!=null){
const response = await coachService.getByKeycloakId(id);
const newCoach: Coach = new Coach();
newCoach.keycloakId = keycloak.tokenParsed.sub || "";
newCoach.email = keycloak.tokenParsed.email || "";
newCoach.nom = keycloak.tokenParsed.family_name || "";
newCoach.prenom = keycloak.tokenParsed.given_name || "";
const response = await coachService.create(newCoach.toDTO());
const coach = new Coach(response.data);
return coach;
}
}
else if(roles.includes("athlete")){
console.error("role = Athlete");
const newAthlete: Athlete = new Athlete();
newAthlete.keycloakId = keycloak.tokenParsed.sub || "";
newAthlete.email = keycloak.tokenParsed.email || "";
newAthlete.nom = keycloak.tokenParsed.family_name || "";
newAthlete.prenom = keycloak.tokenParsed.given_name || "";
const response = await athleteService.create(newAthlete.toDTO());
console.log(response);
else if(roles.includes("athlete")){
const newAthlete: Athlete = new Athlete();
newAthlete.keycloakId = keycloak.tokenParsed.sub || "";
newAthlete.email = keycloak.tokenParsed.email || "";
newAthlete.nom = keycloak.tokenParsed.family_name || "";
newAthlete.prenom = keycloak.tokenParsed.given_name || "";
const response = await athleteService.create(newAthlete.toDTO());
const athlete = new Athlete(response.data);
console.log(athlete);
return athlete;
}
else console.error("Error : role inconnu");