diff --git a/src/main/java/org/ntlab/nemophila/resources/accounts/AccountRest.java b/src/main/java/org/ntlab/nemophila/resources/accounts/AccountRest.java index 3545b59..ecb73cf 100644 --- a/src/main/java/org/ntlab/nemophila/resources/accounts/AccountRest.java +++ b/src/main/java/org/ntlab/nemophila/resources/accounts/AccountRest.java @@ -25,21 +25,30 @@ //ユーザーの削除 @DELETE @Path("/{uid}") - public void deleteAccount(@PathParam("uid") String uid){ + public void deleteAccount(@PathParam("uid") String uid,@FormParam("token") String token){ AccountManager am = AccountManager.getInstance(); - am.deleteAccount(uid); + Account ac = am.getAccount(uid); + if (ac.getToken().equals(token)) { + am.deleteAccount(uid); + } else { + System.out.println("Error : Miss match token"); + } } //パスワードの変更 @PUT @Path("/{uid}/pw") - public void pwChange(@PathParam("uid") String uid, @FormParam("pw") String pw){ + public void pwChange(@PathParam("uid") String uid, @FormParam("oldPw") String oldPw, @FormParam("newPw") String newPw,@FormParam("token") String token){ AccountManager am = AccountManager.getInstance(); Account ac = am.getAccount(uid); - if (ac.getPw().equals(pw)) { - ac.setPw(pw); + if (ac.getToken().equals(token)) { + if (ac.getPw().equals(oldPw)) { + ac.setPw(newPw); + } else { + System.out.println("Error : Miss match pw"); + } } else { - System.out.println("Error : Miss match pw"); + System.out.println("Error : Miss match token"); } } // @@ -52,7 +61,7 @@ if (ac.getToken().equals(token)) { ac.setName(name); } else { - System.out.println("Error : Miss match pw"); + System.out.println("Error : Miss match token"); } }