feat: Mechanisme voor automatische aanmaak en update van accounts aangemaakt.

This commit is contained in:
Gerald Schmittinger 2025-04-08 14:24:57 +02:00
parent 6cb8a1b98f
commit 9339eca9cf
9 changed files with 84 additions and 23 deletions

View file

@ -56,11 +56,11 @@ export async function getTeacher(username: string): Promise<TeacherDTO> {
return mapToTeacherDTO(user);
}
export async function createTeacher(userData: TeacherDTO): Promise<TeacherDTO> {
export async function createTeacher(userData: TeacherDTO, update?: boolean): Promise<TeacherDTO> {
const teacherRepository: TeacherRepository = getTeacherRepository();
const newTeacher = mapToTeacher(userData);
await teacherRepository.save(newTeacher, { preventOverwrite: true });
await teacherRepository.save(newTeacher, { preventOverwrite: !update });
return mapToTeacherDTO(newTeacher);
}