bugfix(user): cambio de username a email del token en CreateRecipeUseCaseImpl

parent d4d8efeb
...@@ -27,12 +27,12 @@ public class CreateRecipeUseCaseImpl implements CreateRecipeUseCase { ...@@ -27,12 +27,12 @@ public class CreateRecipeUseCaseImpl implements CreateRecipeUseCase {
public Recipe create(Recipe recipe) { public Recipe create(Recipe recipe) {
RecipeDocument recipeDocument = mapper.mapDocument(recipe); RecipeDocument recipeDocument = mapper.mapDocument(recipe);
// Get username from token // Get email from token
String username = SecurityContextHolder.getContext().getAuthentication().getName(); String email = SecurityContextHolder.getContext().getAuthentication().getName();
// Search user // Search user
UserDocument user = readUserRepository.readByUsername(username) UserDocument user = readUserRepository.readByEmail(email)
.orElseThrow(() -> new EntityNotFoundException("Usuario con username " + username + " no encontrado")); .orElseThrow(() -> new EntityNotFoundException("Usuario con email " + email + " no encontrado"));
// Put userId to recipe // Put userId to recipe
recipeDocument.setUserId(user.getId()); recipeDocument.setUserId(user.getId());
......
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