|
@ -259,15 +259,27 @@ public class BookController { |
|
|
@PathVariable("hash_id") String bookHashId, |
|
|
@PathVariable("hash_id") String bookHashId, |
|
|
Model dataModel, |
|
|
Model dataModel, |
|
|
HttpServletRequest requestData, |
|
|
HttpServletRequest requestData, |
|
|
HttpServletResponse responseData |
|
|
|
|
|
|
|
|
HttpServletResponse responseData, |
|
|
|
|
|
Authentication authData |
|
|
) { |
|
|
) { |
|
|
|
|
|
|
|
|
|
|
|
String authorities = authData.getAuthorities().toString(); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
Long bookIdFromHash = bookHashRepository.findByHashId(bookHashId).getBookId(); |
|
|
Long bookIdFromHash = bookHashRepository.findByHashId(bookHashId).getBookId(); |
|
|
Book book = bookRepository.findById(bookIdFromHash).get(); |
|
|
Book book = bookRepository.findById(bookIdFromHash).get(); |
|
|
|
|
|
|
|
|
dataModel.addAttribute("book", book); |
|
|
dataModel.addAttribute("book", book); |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* Prevent other than MARKETING users to access hidden book |
|
|
|
|
|
* data even if they knew hash id. |
|
|
|
|
|
*/ |
|
|
|
|
|
if (!book.getPublish() && !authorities.contains("MARKETING") ) { |
|
|
|
|
|
//responseData.setStatus(HttpServletResponse.SC_BAD_REQUEST); |
|
|
|
|
|
return "redirect:/" + bookListPageView; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
httpServerLogger.log(requestData, responseData); |
|
|
httpServerLogger.log(requestData, responseData); |
|
|
return bookEditPageView; |
|
|
return bookEditPageView; |
|
|
|
|
|
|
|
@ -350,6 +362,15 @@ public class BookController { |
|
|
return bookEditPageView; |
|
|
return bookEditPageView; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
* Prevent other than MARKETING users to access hidden book |
|
|
|
|
|
* data even if they knew hash id. |
|
|
|
|
|
*/ |
|
|
|
|
|
if (!book.getPublish() && !authorities.contains("MARKETING") ) { |
|
|
|
|
|
//responseData.setStatus(HttpServletResponse.SC_BAD_REQUEST); |
|
|
|
|
|
return "redirect:/" + bookListPageView; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
/* |
|
|
* More sophisticated methods are required to handle |
|
|
* More sophisticated methods are required to handle |
|
|
* user input with random letter cases etc. considered |
|
|
* user input with random letter cases etc. considered |
|
|