feat: Securisation du Backend

This commit is contained in:
Luc SORIGNET
2026-02-27 10:45:36 +01:00
parent 2fef6d61a4
commit fa843097ba
55 changed files with 2898 additions and 910 deletions

View File

@ -145,18 +145,19 @@ const TeachersSection = ({
// Retourne le profil existant pour un email
const getUsedProfileForEmail = (email) => {
// On cherche tous les profils dont l'email correspond
const matchingProfiles = profiles.filter(p => p.email === email);
const matchingProfiles = profiles.filter((p) => p.email === email);
// On retourne le premier profil correspondant (ou undefined)
const result = matchingProfiles.length > 0 ? matchingProfiles[0] : undefined;
const result =
matchingProfiles.length > 0 ? matchingProfiles[0] : undefined;
return result;
};
// Met à jour le formData et newTeacher si besoin
const updateFormData = (data) => {
setFormData(prev => ({ ...prev, ...data }));
if (newTeacher) setNewTeacher(prev => ({ ...prev, ...data }));
setFormData((prev) => ({ ...prev, ...data }));
if (newTeacher) setNewTeacher((prev) => ({ ...prev, ...data }));
};
// Récupération des messages d'erreur pour un champ donné
@ -171,7 +172,9 @@ const TeachersSection = ({
const existingProfile = getUsedProfileForEmail(email);
if (existingProfile) {
logger.info(`Adresse email déjà utilisée pour le profil ${existingProfile.id}`);
logger.info(
`Adresse email déjà utilisée pour le profil ${existingProfile.id}`
);
}
updateFormData({
@ -202,8 +205,8 @@ const TeachersSection = ({
logger.debug('[DELETE] Suppression teacher id:', id);
return handleDelete(id)
.then(() => {
setTeachers(prevTeachers =>
prevTeachers.filter(teacher => teacher.id !== id)
setTeachers((prevTeachers) =>
prevTeachers.filter((teacher) => teacher.id !== id)
);
logger.debug('[DELETE] Teacher supprimé:', id);
})
@ -247,13 +250,13 @@ const TeachersSection = ({
createdTeacher.profile
) {
newProfileId = createdTeacher.profile;
foundProfile = profiles.find(p => p.id === newProfileId);
foundProfile = profiles.find((p) => p.id === newProfileId);
}
setTeachers([createdTeacher, ...teachers]);
setNewTeacher(null);
setLocalErrors({});
setFormData(prev => ({
setFormData((prev) => ({
...prev,
existingProfileId: newProfileId,
}));
@ -419,7 +422,7 @@ const TeachersSection = ({
case 'SPECIALITES':
return (
<div className="flex justify-center space-x-2 flex-wrap">
{teacher.specialities_details.map((speciality) => (
{(teacher.specialities_details ?? []).map((speciality) => (
<SpecialityItem
key={speciality.id}
speciality={speciality}