fix: challenge 7 (#1433)
This commit is contained in:
@ -23,26 +23,27 @@
|
||||
package org.owasp.webgoat.webwolf.mailbox;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class MailboxController {
|
||||
|
||||
private final MailboxRepository mailboxRepository;
|
||||
|
||||
@GetMapping(value = "/mail")
|
||||
@GetMapping("/mail")
|
||||
public ModelAndView mail() {
|
||||
UserDetails user =
|
||||
(UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
@ -56,9 +57,15 @@ public class MailboxController {
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/mail")
|
||||
public ResponseEntity<?> sendEmail(@RequestBody Email email) {
|
||||
@PostMapping("/mail")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public void sendEmail(@RequestBody Email email) {
|
||||
mailboxRepository.save(email);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).build();
|
||||
}
|
||||
|
||||
@DeleteMapping("/mail")
|
||||
@ResponseStatus(HttpStatus.ACCEPTED)
|
||||
public void deleteAllMail() {
|
||||
mailboxRepository.deleteAll();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user