correction id coach bug
This commit is contained in:
@@ -35,6 +35,7 @@ export const CreateSession = () => {
|
||||
|
||||
async function handleCreateSession() {
|
||||
if(user instanceof Coach){
|
||||
session.name = name;
|
||||
session.groupe = groupe;
|
||||
session.creneau = creneau;
|
||||
session.duree = duree;
|
||||
|
||||
@@ -22,12 +22,14 @@ 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.create(id);
|
||||
const admin = new Admin(response.data);
|
||||
return admin;
|
||||
}
|
||||
const newAdmin: Admin = new Admin();
|
||||
newAdmin.keycloakId = keycloak.tokenParsed.sub || "";
|
||||
newAdmin.email = keycloak.tokenParsed.email || "";
|
||||
newAdmin.nom = keycloak.tokenParsed.family_name || "";
|
||||
newAdmin.prenom = keycloak.tokenParsed.given_name || "";
|
||||
const response = await athleteService.create(newAdmin.toDTO());
|
||||
const admin = new Admin(response.data);
|
||||
return admin;
|
||||
}
|
||||
else if(roles.includes("coach")){
|
||||
const newCoach: Coach = new Coach();
|
||||
|
||||
Reference in New Issue
Block a user