Skip to content

Commit

Permalink
🐛 [Fix] access token 유효 시간 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunjin3395 committed Dec 8, 2024
1 parent 1038704 commit 55a9a83
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/com/gamegoo/filter/LoginFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class LoginFilter extends UsernamePasswordAuthenticationFilter {
private final RefreshTokenRepository refreshTokenRepository;

public LoginFilter(AuthenticationManager authenticationManager, JWTUtil jwtUtil,
MemberRepository memberRepository, RefreshTokenRepository refreshTokenRepository) {
MemberRepository memberRepository, RefreshTokenRepository refreshTokenRepository) {
this.authenticationManager = authenticationManager;
this.jwtUtil = jwtUtil;
this.memberRepository = memberRepository;
Expand All @@ -49,7 +49,7 @@ public LoginFilter(AuthenticationManager authenticationManager, JWTUtil jwtUtil,

@Override
public Authentication attemptAuthentication(HttpServletRequest request,
HttpServletResponse response) throws AuthenticationException {
HttpServletResponse response) throws AuthenticationException {
// 클라이언트 요청에서 username, password 추출
String email = obtainUsername(request);
String password = obtainPassword(request);
Expand All @@ -69,15 +69,15 @@ public Authentication attemptAuthentication(HttpServletRequest request,
// 로그인 성공시 실행하는 메소드 (JWT 발급)
@Override
protected void successfulAuthentication(HttpServletRequest request,
HttpServletResponse response, FilterChain chain,
Authentication authentication) throws IOException {
HttpServletResponse response, FilterChain chain,
Authentication authentication) throws IOException {
CustomUserDetails customUserDetails = (CustomUserDetails) authentication.getPrincipal();

// 사용자 id 불러오기
Long id = customUserDetails.getId();

// jwt 토큰 생성
String access_token = jwtUtil.createJwtWithId(id, 60 * 1000L); // 1분
String access_token = jwtUtil.createJwtWithId(id, 60 * 60 * 1000L); // 1시간
String refresh_token = jwtUtil.createJwt(60 * 60 * 24 * 30 * 1000L); // 30일

Member member = memberRepository.findById(id).orElseThrow();
Expand Down Expand Up @@ -119,8 +119,8 @@ protected void successfulAuthentication(HttpServletRequest request,
// 로그인 실패시 실행하는 메소드
@Override
protected void unsuccessfulAuthentication(HttpServletRequest request,
HttpServletResponse response,
AuthenticationException failed) throws IOException {
HttpServletResponse response,
AuthenticationException failed) throws IOException {
// 어떤 에러인지 확인
ErrorStatus errorStatus = getErrorStatus(failed);

Expand Down

0 comments on commit 55a9a83

Please sign in to comment.