-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JT-29] JWT 로그인 기능 구현 #9
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셧심다 🫡
member.updateLastLogin(); | ||
return jwtProvider.generateToken(logInReq.email()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R: return 전에 줄바꿈 해주시요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R:
Member member = memberRepository.findByEmail(logInReq.email()).orElseThrow(
() -> new BadCredentialsException("너 안돼!")
);
Member member = memberRepository.findByEmail(logInReq.email())
.orElseThrow(() -> new BadCredentialsException("너 안돼!"));
@Override | ||
protected void doFilterInternal(HttpServletRequest request, @NotNull HttpServletResponse response, | ||
@NotNull FilterChain filterChain) throws ServletException, IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R: 파라미터 길어지면 코틀린 컨벤션으루
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R: 함정 있음
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R: 예외 시, 다음 필터안가게 리턴!
@Value("${jwt.secret.key}") | ||
private String salt; | ||
|
||
@Value("${jwt.iss}") | ||
private String iss; | ||
|
||
@Value("${jwt.expire}") | ||
private long expire; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R: 설정 파일에서 @Value
로 값 가져오는 경우엔 상수인걸 명시하기 위해서 대문자로 표기하기로 햇슴다!
headers.put("typ", "JWT"); | ||
return headers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R: 줄바꿈 해주세용
.build().parseClaimsJws(token); | ||
if (claimsJws.getBody().getExpiration().before(new Date())) { | ||
throw new RuntimeException("Token Expired"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R: 요기도 블록일 때 줄바꿈 하기로 했던 듯요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A: claimsJws.getBody().getExpiration().before(new Date()) 요거 따로 private 메서드로 빼도 좋을 것 같아요! 음 예를들면 isTokenExpired ..
member.updateLastLogin(); | ||
return jwtProvider.generateToken(logInReq.email()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R:
Member member = memberRepository.findByEmail(logInReq.email()).orElseThrow(
() -> new BadCredentialsException("너 안돼!")
);
Member member = memberRepository.findByEmail(logInReq.email())
.orElseThrow(() -> new BadCredentialsException("너 안돼!"));
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R: 예외 시, 다음 필터안가게 리턴!
String email = Jwts.parserBuilder() | ||
.setSigningKey(secretKey) | ||
.build().parseClaimsJws(token).getBody().getSubject(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R: 의미없는 줄바꿈!~
@Override | ||
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { | ||
Member member = memberRepository.findByEmail(email).orElseThrow( | ||
() -> new UsernameNotFoundException("Invalid Email") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위에서 말했어용!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
체이닝~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른분들이 이미 열시미 남겨주시기도 했고 컨벤션 관련된거 말고는 크게 수정할 건 없을 것 같아요
고생하셨씀다 갠적인 궁금증은 물어보러 가겠슴두
public String login(LogInReq logInReq) { | ||
Member member = memberRepository.findByEmail(logInReq.email()).orElseThrow( | ||
() -> new BadCredentialsException("너 안돼!") | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R: 요런식으로 많이 썼던 것 같아요 !
Member member = memberRepository.findByEmail(logInReq.email())
.orElseThrow(() -> new BadCredentialsException("너 안돼!"));
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { | ||
Member member = memberRepository.findByEmail(email).orElseThrow( | ||
() -> new UsernameNotFoundException("Invalid Email") | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R: 요기도 마찬가지 !!
📌 개발 내용
📑 PR 포인트
추후 기능
Interceptor
와ThreadLocal
사용 예정👥 협업을 위한 코드리뷰
✅ 리마인더
⚙️ 코드리뷰 룰