diff --git a/src/main/java/org/ntlab/nemophila/resources/accounts/AccountPostRest.java b/src/main/java/org/ntlab/nemophila/resources/accounts/AccountPostRest.java index d496aca..9bcb53a 100644 --- a/src/main/java/org/ntlab/nemophila/resources/accounts/AccountPostRest.java +++ b/src/main/java/org/ntlab/nemophila/resources/accounts/AccountPostRest.java @@ -28,6 +28,10 @@ if (image3 != null) post.setImage3(image3); if (rate != null) post.setRate(rate); if (comment != null) post.setComment(comment); + } else { + var response = Response.status(Response.Status.NO_CONTENT); + response.status(401).entity("tokenの認証に失敗"); + throw new WebApplicationException(response.build()); } } @@ -37,16 +41,24 @@ AccountManager am = AccountManager.getInstance(); Account account = am.getAccount(uid); - if(account != null){ - Post post = account.getPost(pid); - - if(post == null){ + if (account.getToken().equals(token)) { + if (account != null) { + Post post = account.getPost(pid); + if (post != null) { + account.deletePost(pid); + } else { + var response = Response.status(Response.Status.NO_CONTENT); + response.status(404).entity("投稿が存在しません"); + throw new WebApplicationException(response.build()); + } var response = Response.status(Response.Status.NO_CONTENT); - response.status(404).entity("投稿が存在しません"); + response.status(404).entity("アカウントが存在しません"); throw new WebApplicationException(response.build()); - } else { - account.deletePost(pid); } + } else { + var response = Response.status(Response.Status.NO_CONTENT); + response.status(401).entity("tokenの認証に失敗"); + throw new WebApplicationException(response.build()); } } }