Skip to content

Commit

Permalink
[fix] : CustomOauth2User 객체가 아닌 Member 객체를 인증 객채로 생성되도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
dudxo committed Aug 2, 2024
1 parent 4806bcb commit e99cf34
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
import org.springframework.util.StringUtils;

import com.dnd.gongmuin.common.exception.runtime.CustomJwtException;
import com.dnd.gongmuin.member.domain.Member;
import com.dnd.gongmuin.member.service.MemberService;
import com.dnd.gongmuin.security.jwt.exception.JwtErrorCode;
import com.dnd.gongmuin.security.oauth2.AuthInfo;
import com.dnd.gongmuin.security.oauth2.CustomOauth2User;
import com.dnd.gongmuin.security.service.TokenService;

Expand All @@ -41,6 +42,7 @@ public class TokenProvider {
private static final long ACCESS_TOKEN_EXPIRE_TIME = 1000 * 60 * 30L;
private static final long REFRESH_TOKEN_EXPIRE_TIME = 1000 * 60 * 60 * 24L;
private final TokenService tokenService;
private final MemberService memberService;

@PostConstruct
private void initSecretKey() {
Expand Down Expand Up @@ -84,8 +86,8 @@ public Authentication getAuthentication(String token) {
Claims claims = parseToken(token);
List<SimpleGrantedAuthority> authorities = getAuthorities(claims);

AuthInfo authInfo = AuthInfo.fromSocialEmail(claims.getSubject());
CustomOauth2User principal = new CustomOauth2User(authInfo);
String socialEmail = claims.getSubject();
Member principal = memberService.getMemberBySocialEmail(socialEmail);

return new UsernamePasswordAuthenticationToken(principal, token, authorities);
}
Expand Down

0 comments on commit e99cf34

Please sign in to comment.