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

@ -52,11 +52,11 @@ export async function getStudent(username: string): Promise<StudentDTO> {
return mapToStudentDTO(user);
}
export async function createStudent(userData: StudentDTO): Promise<StudentDTO> {
export async function createStudent(userData: StudentDTO, allowUpdate: boolean = false): Promise<StudentDTO> {
const studentRepository = getStudentRepository();
const newStudent = mapToStudent(userData);
await studentRepository.save(newStudent, { preventOverwrite: true });
await studentRepository.save(newStudent, { preventOverwrite: !allowUpdate });
return userData;
}

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);
}