check session
This commit is contained in:
@@ -33,6 +33,9 @@ public class PostCommnadServiceImpl implements PostCommandService{
|
|||||||
@Override
|
@Override
|
||||||
public Post createPost(Post post, HttpSession httpSession){
|
public Post createPost(Post post, HttpSession httpSession){
|
||||||
UserEntity userEntity = (UserEntity) httpSession.getAttribute("user");
|
UserEntity userEntity = (UserEntity) httpSession.getAttribute("user");
|
||||||
|
if(userEntity == null){
|
||||||
|
throw new ExpiredSessionException("만료된 세션");
|
||||||
|
}
|
||||||
LocalDateTime createdAt = LocalDateTime.now();
|
LocalDateTime createdAt = LocalDateTime.now();
|
||||||
|
|
||||||
Post postEntity = postCommandRepository.save(
|
Post postEntity = postCommandRepository.save(
|
||||||
@@ -61,6 +64,9 @@ public class PostCommnadServiceImpl implements PostCommandService{
|
|||||||
@Override
|
@Override
|
||||||
public Post updatePost(Long id, Post post, HttpSession httpSession){
|
public Post updatePost(Long id, Post post, HttpSession httpSession){
|
||||||
UserEntity userEntity = (UserEntity) httpSession.getAttribute("user");
|
UserEntity userEntity = (UserEntity) httpSession.getAttribute("user");
|
||||||
|
if(userEntity == null){
|
||||||
|
throw new ExpiredSessionException("만료된 세션");
|
||||||
|
}
|
||||||
Post postEntity = postCommandRepository.findByIdAndWriter(id, userEntity).orElseThrow(() -> new NotFoundException(id + " post not found"));
|
Post postEntity = postCommandRepository.findByIdAndWriter(id, userEntity).orElseThrow(() -> new NotFoundException(id + " post not found"));
|
||||||
|
|
||||||
postEntity.setConent(post.getContent());
|
postEntity.setConent(post.getContent());
|
||||||
@@ -84,7 +90,6 @@ public class PostCommnadServiceImpl implements PostCommandService{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deletePost(Long id, HttpSession httpSession){
|
public void deletePost(Long id, HttpSession httpSession){
|
||||||
// TODO: 이 때 세션이 만기되면 어떡함
|
|
||||||
UserEntity userEntity = (UserEntity)httpSession.getAttribute("user");
|
UserEntity userEntity = (UserEntity)httpSession.getAttribute("user");
|
||||||
if(userEntity == null){
|
if(userEntity == null){
|
||||||
throw new ExpiredSessionException("만료된 세션");
|
throw new ExpiredSessionException("만료된 세션");
|
||||||
|
|||||||
Reference in New Issue
Block a user