getUser
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import api, { activiteService, sessionService } from "./api";
|
||||
import api, { activiteService, athleteService, coachService, sessionService } from "./api";
|
||||
import { Activite, Admin, Athlete, Coach, Session, User } from "./classes";
|
||||
import Keycloak from 'keycloak-js'
|
||||
import { AdminDTO, AthleteDTO, CoachDTO } from "./classesDTO";
|
||||
@@ -20,17 +20,17 @@ export async function getUser(keycloak:Keycloak): Promise<User|null>{
|
||||
const roles = keycloak.tokenParsed?.realm_access?.roles
|
||||
if(roles!=null){
|
||||
if(roles.includes("admin")){
|
||||
const response = await api.get<AdminDTO>(`/TODO`);
|
||||
const response = await athleteService.create(keycloak.tokenParsed);
|
||||
const admin = new Admin(response.data);
|
||||
return admin;
|
||||
}
|
||||
else if(roles.includes("coach")){
|
||||
const response = await api.get<CoachDTO>(`/TODO`);
|
||||
const response = await coachService.create(keycloak.tokenParsed);
|
||||
const coach = new Coach(response.data);
|
||||
return coach;
|
||||
}
|
||||
else if(roles.includes("athletes")){
|
||||
const response = await api.get<AthleteDTO>(`/TODO`);
|
||||
const response = await athleteService.create(keycloak.tokenParsed);
|
||||
const athlete = new Athlete(response.data);
|
||||
return athlete;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user