feat: frontend call now include the token and send the email from the token to backen servie
All checks were successful
Format / formatting (push) Successful in 6s
CI / build (push) Successful in 11s

This commit is contained in:
Pierre Tellier
2025-02-19 12:09:37 +01:00
parent 04a73073c1
commit 4698aa549f
6 changed files with 72 additions and 50 deletions

View File

@ -5,6 +5,8 @@ import enseirb.myinpulse.service.AdminApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.web.bind.annotation.*;
@SpringBootApplication
@ -24,8 +26,8 @@ public class AdminApi {
* @return a list of all project managed by the current admin user
*/
@GetMapping("/admin/projects")
public Iterable<Administrateurs> getProjects() {
return adminApiService.getProjects();
public Iterable<Administrateurs> getProjects(@AuthenticationPrincipal Jwt principal) {
return adminApiService.getProjects(principal.getClaimAsString("email"));
}
/**
@ -34,8 +36,8 @@ public class AdminApi {
* @return a list of upcoming appointments for the current user
*/
@GetMapping("/admin/appointments/upcoming")
public Iterable<Appointment> getUpcomingAppointments() {
return adminApiService.getUpcomingAppointments();
public Iterable<Appointment> getUpcomingAppointments(@AuthenticationPrincipal Jwt principal) {
return adminApiService.getUpcomingAppointments(principal.getClaimAsString("email"));
}
/**
@ -51,6 +53,8 @@ public class AdminApi {
/**
* Endpoint used to make a decision about a project.
*
* <p>The decision must contains the administrator
*
* @return the status code of the request
*/
@PostMapping("/admin/projects/decision")
@ -77,8 +81,11 @@ public class AdminApi {
*/
@PostMapping("/admin/appoitements/report/{appointmentId}")
public void createAppointmentReport(
@PathVariable String appointmentId, @RequestBody Report report) {
adminApiService.createAppointmentReport(appointmentId, report);
@PathVariable String appointmentId,
@RequestBody Report report,
@AuthenticationPrincipal Jwt principal) {
adminApiService.createAppointmentReport(
appointmentId, report, principal.getClaimAsString("email"));
}
/**