Changeset a64c772 for backend/src
- Timestamp:
- 05/25/26 13:43:53 (4 months ago)
- Branches:
- master
- Children:
- f18b11b
- Parents:
- 84249b1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
backend/src/main/java/medora/controller/AppointmentController.java
r84249b1 ra64c772 243 243 } 244 244 245 // Verify appointment exists and check permissions for patients245 // Verify appointment exists and check permissions 246 246 Appointment appointment = appointmentService.getAppointmentById(appointmentId) 247 247 .orElseThrow(() -> new RuntimeException("Appointment not found")); … … 251 251 Long appointmentPatientId = appointment.getPatient() != null ? appointment.getPatient().getPatientId() : null; 252 252 if (patientIdFromToken == null || !patientIdFromToken.equals(appointmentPatientId)) { 253 return ResponseEntity.status(HttpStatus.FORBIDDEN) 254 .body(Map.of("error", "You can only cancel your own appointments")); 255 } 256 } else if (role.equals("DOCTOR")) { 257 Long doctorIdFromToken = securityUtil.getDoctorIdFromRequest(httpRequest); 258 Long appointmentDoctorId = appointment.getDoctor() != null ? appointment.getDoctor().getDoctorId() : null; 259 if (doctorIdFromToken == null || !doctorIdFromToken.equals(appointmentDoctorId)) { 253 260 return ResponseEntity.status(HttpStatus.FORBIDDEN) 254 261 .body(Map.of("error", "You can only cancel your own appointments"));
Note:
See TracChangeset
for help on using the changeset viewer.
