package zw.qantra.tm.domain.controllers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.web.bind.annotation.*; import zw.qantra.tm.domain.services.EmailService; @RestController @RequestMapping("/test") @CrossOrigin(origins = "*") public class TestController { @Autowired private EmailService emailService; @GetMapping("/hello/{email}") public ResponseEntity helloEndpoint(@PathVariable String email) { emailService.sendSimpleMessage(email, "Hello", "Hello World!"); return ResponseEntity.ok("Hello World!"); } @GetMapping("/protected") public ResponseEntity protectedEndpoint() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String username = authentication.getName(); return ResponseEntity.ok("Hello " + username + "! This is a protected endpoint."); } @GetMapping("/public") public ResponseEntity publicEndpoint() { return ResponseEntity.ok("This is a public endpoint - no authentication required!"); } }