Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ResponseEntity<?> updateStudent(@PathVariable int id, @RequestBody Studen
return new ResponseEntity<>("User not found", HttpStatus.NOT_FOUND);
}

Profile profile = profileRepository.findById(id).orElse(null);
Profile profile = profileRepository.findById(user.getProfile().getId()).orElse(null);
if (profile == null) {
return new ResponseEntity<>("Profile not found", HttpStatus.NOT_FOUND);
}
Expand Down Expand Up @@ -89,7 +89,12 @@ public ResponseEntity<?> updateStudent(@PathVariable int id, @RequestBody Studen
profile.setGithubUrl(studentRequest.getGithub_username());
}


if (studentRequest.getEmail() != null) {
boolean emailExists = userRepository.existsByEmail(studentRequest.getEmail());
if (emailExists && !studentRequest.getEmail().equals(user.getEmail())){
return new ResponseEntity<>("Email is already in use", HttpStatus.BAD_REQUEST);
}
user.setEmail(studentRequest.getEmail());
}

Expand Down
Loading