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

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