add registration
This commit is contained in:
@@ -8,11 +8,31 @@ import { useLocalData } from '../context/useLocalData';
|
||||
|
||||
export const Login =() =>{
|
||||
const {user,setUser} = useLocalData()
|
||||
const { keycloak } = useKeycloak();
|
||||
useEffect(() => {
|
||||
if (keycloak.authenticated) {
|
||||
fetch("http://localhost:8080/api/athlete/create", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${keycloak.token}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
}, [keycloak.authenticated]);
|
||||
|
||||
|
||||
useEffect(() => { //TODO à supprimer
|
||||
setUser(getUserTest())
|
||||
},[]);
|
||||
useEffect(() => {
|
||||
if (keycloak.authenticated) {
|
||||
const tokenParsed = keycloak.tokenParsed;
|
||||
setUser({
|
||||
id: tokenParsed?.id,
|
||||
email: tokenParsed?.email,
|
||||
nom: tokenParsed?.family_name,
|
||||
prenom: tokenParsed?.given_name,
|
||||
role: "Athlete",
|
||||
sessions: []
|
||||
});
|
||||
}
|
||||
}, [keycloak.authenticated]);
|
||||
|
||||
|
||||
function handleLogin(): void {
|
||||
@@ -24,8 +44,6 @@ export const Login =() =>{
|
||||
keycloak.logout()
|
||||
setUser(new User());
|
||||
}
|
||||
|
||||
const { keycloak } = useKeycloak()
|
||||
return(
|
||||
<div>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user