Skip to content

Commit

Permalink
fix: AuditorAware가 세션에서만 찾기 때문에 자동로그인 시(쿠키)에는 예약이 불가능한 현상 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
nuyh99 committed Jan 16, 2024
1 parent adc289a commit e11ec3b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public Object resolveArgument(final MethodParameter parameter,
}

final HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
return autoLoginManager.getAuthentication(request);
final Authentication autoLoggedIn = autoLoginManager.getAuthentication(request);

request.getSession().setAttribute(AUTHORIZATION, autoLoggedIn);
return autoLoggedIn;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.example.busan.member.domain.Role;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -112,6 +113,8 @@ void resolve_auto() {
.when(methodParameter).getParameterType();
given(request.getNativeRequest(HttpServletRequest.class))
.willReturn(httpServletRequest);
given(httpServletRequest.getSession())
.willReturn(mock(HttpSession.class));
given(httpServletRequest.getCookies())
.willReturn(new Cookie[]{new Cookie(AutoLoginManager.AUTO_LOGIN_COOKIE_NAME, "fajselkfjalksej")});

Expand Down

0 comments on commit e11ec3b

Please sign in to comment.