Skip to content

Commit

Permalink
Merge pull request #103 from Recipe-Project/feature/add_aop
Browse files Browse the repository at this point in the history
Feature/add aop
  • Loading branch information
joona95 authored Aug 10, 2024
2 parents a4a3875 + b724947 commit afd41b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Object loginCheck(ProceedingJoinPoint proceedingJoinPoint) throws Throwab

Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

if (authentication == null) {
if (authentication == null || !(authentication.getPrincipal() instanceof SecurityUser)) {
throw new UserTokenNotExistException();
}

Expand Down
8 changes: 2 additions & 6 deletions src/main/java/com/recipe/app/src/user/api/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
import com.recipe.app.src.user.application.dto.UserTokenRefreshRequest;
import com.recipe.app.src.user.application.dto.UserTokenRefreshResponse;
import com.recipe.app.src.user.domain.User;
import com.recipe.app.src.user.exception.UserTokenNotExistException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
Expand Down Expand Up @@ -108,10 +106,8 @@ public void deleteUser(HttpServletRequest request, @ApiIgnore User user) {

@ApiOperation(value = "로그아웃 API")
@PostMapping("/logout")
public void logout(HttpServletRequest request, @ApiIgnore final Authentication authentication) {

if (authentication == null)
throw new UserTokenNotExistException();
@LoginCheck
public void logout(HttpServletRequest request, @ApiIgnore User user) {

userService.logout(request);
}
Expand Down

0 comments on commit afd41b8

Please sign in to comment.