Take email:pass instead of Account Body to delete

This commit is contained in:
Tim
2025-06-15 12:33:43 +02:00
parent 29ab557da3
commit 731bc3d154

View File

@@ -75,16 +75,19 @@ public class AccountController {
@RequestMapping(path = ACCOUNT_BASE, method = RequestMethod.DELETE, produces = "application/json")
public ResponseEntity<Void> deleteAccount(HttpServletRequest request,
@RequestBody Account account) {
@RequestParam(PARAM_EMAIL) String email,
@RequestParam(PARAM_PASSWORD) String password) {
logRequest(request);
if (validatorService.isInvalid(account)) {
log.warn("[{}] failed Validation, sending bad request", request.getRequestURI());
if (!accountService.existsWithEmail(email)) {
log.warn("[{}] Account doesn't exist", request.getRequestURI());
return ResponseEntity.badRequest().build();
}
if (accountService.existsWithEmail(account.getEmail())) {
Account acc = accountService.isValidLogin(email, password);
if (acc == null) {
log.warn("[{}] Invalid Credentials", request.getRequestURI());
return ResponseEntity.badRequest().build();
}
if (!accountService.deleteIfExists(account)) {
if (!accountService.deleteIfExists(acc)) {
return ResponseEntity.badRequest().build();
}
return ResponseEntity.ok().build();