Skip to content
Snippets Groups Projects
Commit 0f982325 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

cannot read someone else's article if not published yet

parent fa69ac6e
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,7 @@ public class ArticlesApi {
}
else
{
queryString += " AND status='published'";
if(team != null && team)
{
// TODO: decide if this is needed
......@@ -182,15 +183,24 @@ public class ArticlesApi {
@ApiParam(value = "slug", required = true) @PathVariable("slug") String slug
) {
User user = mipApplication.getUser();
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Article article = null;
try{
session.beginTransaction();
article = (Article) session
.createQuery("FROM Article WHERE slug= :slug")
.setString("slug", slug)
.uniqueResult();
session.getTransaction().commit();
if (!article.getStatus().equals("published") && !article.getCreatedBy().getUsername().equals(user.getUsername()))
{
return ResponseEntity.status(HttpStatus.FORBIDDEN).body(null);
}
} catch (Exception e)
{
if(session.getTransaction() != null)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment