diff --git a/src/main/java/de/thm/arsnova/services/QuestionService.java b/src/main/java/de/thm/arsnova/services/QuestionService.java index 406be88d01402d9de0d6e94e68476f14b225aee3..4c1b2c2d867abb6c7260f1bd3ccfa690abc5d039 100644 --- a/src/main/java/de/thm/arsnova/services/QuestionService.java +++ b/src/main/java/de/thm/arsnova/services/QuestionService.java @@ -436,12 +436,13 @@ public class QuestionService implements IQuestionService, ApplicationEventPublis @PreAuthorize("isAuthenticated()") public Answer updateAnswer(final Answer answer) { final User user = userService.getCurrentUser(); - if (user == null || !user.getUsername().equals(answer.getUser())) { + final Answer realAnswer = this.getMyAnswer(answer.getQuestionId()); + if (user == null || realAnswer == null || !user.getUsername().equals(realAnswer.getUser())) { throw new UnauthorizedException(); } final Question question = getQuestion(answer.getQuestionId()); - final Answer result = databaseDao.updateAnswer(answer); + final Answer result = databaseDao.updateAnswer(realAnswer); final Session session = databaseDao.getSessionFromKeyword(question.getSessionKeyword()); this.publisher.publishEvent(new NewAnswerEvent(this, result, user, question, session));