bugfix(recipe/controller): usado id del usuario en lugar de email para autorización

parent 8d4b97d6
...@@ -23,16 +23,13 @@ public class DeleteRecipeController { ...@@ -23,16 +23,13 @@ public class DeleteRecipeController {
private final ReadRecipeUseCase readRecipeUseCase; private final ReadRecipeUseCase readRecipeUseCase;
private final ReadUserUseCase readUserUseCase;
@DeleteMapping("/{id}") @DeleteMapping("/{id}")
public ResponseEntity<String> delete(@PathVariable String id) { public ResponseEntity<String> delete(@PathVariable String id) {
Recipe recipe = readRecipeUseCase.readById(id); Recipe recipe = readRecipeUseCase.readById(id);
String email = SecurityContextHolder.getContext().getAuthentication().getName(); String userId = SecurityContextHolder.getContext().getAuthentication().getName();
User user = readUserUseCase.readByEmail(email);
if (!recipe.getUserId().equals(user.getId())) if (!recipe.getUserId().equals(userId))
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build(); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
service.delete(id); service.delete(id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment