@@ -44,18 +44,24 @@ public Authentication attemptAuthentication(HttpServletRequest request, HttpServ
4444 @ Override
4545 protected void successfulAuthentication (HttpServletRequest request , HttpServletResponse response , FilterChain chain , Authentication authResult ) {
4646 response .setStatus (HttpServletResponse .SC_OK );
47+ String userId = authResult .getName ();
48+ String role = extractRole (authResult );
4749 EncodedToken accessToken =
4850 generateTokensOnLoginUseCase .saveRefreshTokenAndReturnAccessToken (
49- UUID .fromString (authResult .getName ()),
50- UserRole .from (authResult .getAuthorities ().stream ()
51- .findFirst ()
52- .map (GrantedAuthority ::getAuthority )
53- .orElseThrow (() -> new IllegalStateException ("유저 권한 자체가 존재하지 않습니다." ))));
51+ UUID .fromString (userId ),
52+ UserRole .from (role ));
5453
5554 response .setHeader ("Authorization" , accessToken .getValueWithPrefix ());
5655 // cookieUseCase.setAccessToken(response, accessToken.value());
5756 }
5857
58+ private static String extractRole (Authentication authResult ) {
59+ return authResult .getAuthorities ().stream ()
60+ .findFirst ()
61+ .map (GrantedAuthority ::getAuthority )
62+ .orElseThrow (() -> new IllegalStateException ("유저 권한 자체가 존재하지 않습니다." ));
63+ }
64+
5965 @ Override
6066 protected void unsuccessfulAuthentication (HttpServletRequest request , HttpServletResponse response , AuthenticationException failed ) throws IOException {
6167 ProblemDetail problemDetail = buildUnauthorizedProblemDetail (failed );
0 commit comments