forked from codesquad-members-2024/issue-tracker
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 로그아웃 구현 및 리프레시 토큰 ㄱedis에 저장 및 삭제 기능 구현
- 로그인시 리프레시 토큰을 redis에 저장하고, 로그아웃 요청시 redis에 저장된 refresh 토큰을 삭제
- Loading branch information
1 parent
72c3258
commit d9b34df
Showing
6 changed files
with
106 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
be/issue-tracker/src/main/java/com/issuetracker/member/util/TokenStoreManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.issuetracker.member.util; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.stereotype.Component; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class TokenStoreManager { | ||
private final RedisTemplate<String, String> redisTemplate; | ||
|
||
public void saveRefreshToken(String memberId, String refreshToken, long timeout) { | ||
redisTemplate.opsForValue().set(memberId, refreshToken, timeout, TimeUnit.MILLISECONDS); | ||
} | ||
|
||
public String getRefreshToken(String memberId) { | ||
return redisTemplate.opsForValue().get(memberId); | ||
} | ||
|
||
public void deleteRefreshToken(String memberId) { | ||
redisTemplate.delete(memberId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters