diff --git a/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java b/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java index 3134994..c21990a 100644 --- a/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java +++ b/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java @@ -1,9 +1,11 @@ package org.ntlab.citrusserver.resources; import jakarta.ws.rs.*; import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; import org.ntlab.citrusserver.entities.Account; import org.ntlab.citrusserver.repositories.AccountManager; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import java.util.ArrayList; @@ -66,9 +68,11 @@ @FormParam("new_password")String newPassword, @FormParam("old_password")String oldPassword, @FormParam("token") String token){ - if(accountManager.checkToken(accountId, token) == true) { + if(accountManager.checkToken(accountId, token)== true) { accountManager.changePassword(accountId, newPassword, oldPassword, token); } + var response = Response.status(Response.Status.FORBIDDEN).entity("認証失敗");//forbiddenは403 + throw new WebApplicationException(response.build()); } // 指定されたIDの自己紹介を返す(GET) @@ -89,6 +93,8 @@ if(accountManager.checkToken(accountId, token) == true) { accountManager.changeIntroduction(accountId, introduction, token); } + var response = Response.status(Response.Status.FORBIDDEN).entity("認証失敗");//forbiddenは403 + throw new WebApplicationException(response.build()); } ///////// // @Path("/{account_id}/photo") @@ -124,7 +130,8 @@ if(accountManager.checkToken(accountId, token) == true) { return accountManager.FavoritesBookId(accountId, otherAccountId, token); } - return null; + var response = Response.status(Response.Status.FORBIDDEN).entity("認証失敗");//forbiddenは403 + throw new WebApplicationException(response.build()); } //////////