현재 프로젝트에서는 아래와 같이 각 컨트롤러 메서드에서 HttpSession 을 직접 호출하여 로그인 정보를 가져오고 있다.

@PostMapping("/signup/complete")
    public String completeSignUp(Model model, @ModelAttribute AdditionalInfoRequestDto requestDto){
        // 1. 세션에서 소셜 로그인 정보 가져오기
        OAuthAttributes socialAttributes = (OAuthAttributes) httpSession.getAttribute("social_info");

이러한 방식은 다른 컨트롤러나 메서드에서도 동일하게 반복된다.

현재 방식의 문제점

  1. 반복적인 코드
  1. 컨트롤러의 책임 증가

LoginUser 에노테이션

 @Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface LoginUser {
	 //HttpSession에서 가져올 속성(attribute)의 키 값을 지정한다.
	 @NotNull
   String value();
}

1. Target(ElementType.PARAMETER)

이 코드는 @LoginUser 에노테이션을 붙일 수 있는 위치를 지정한다.

2. @Retention(RetentionPolicy.RUNTIME)

이 코드는 에노테이션의 정보가 유지되는 기간을 지정한다.