-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat:refreshToken으로 accessToken발급,로그아웃 구현
- Loading branch information
Showing
8 changed files
with
242 additions
and
44 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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/cmc/monggeul/domain/user/dto/PostLogoutRes.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,12 @@ | ||
package com.cmc.monggeul.domain.user.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Builder | ||
public class PostLogoutRes { | ||
|
||
private String userEmail; | ||
|
||
} |
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
40 changes: 40 additions & 0 deletions
40
src/main/java/com/cmc/monggeul/global/config/redis/RedisDao.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,40 @@ | ||
package com.cmc.monggeul.global.config.redis; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.core.ValueOperations; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.time.Duration; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class RedisDao { | ||
|
||
private final RedisTemplate<String, Object> redisTemplate; | ||
|
||
public void setValues(String key, String data) { | ||
ValueOperations<String, Object> values = redisTemplate.opsForValue(); | ||
values.set(key, data); | ||
} | ||
// redisTemplate.opsForValue() | ||
// .set("RT:" + authentication.getName(),tokenDto.getRefreshToken(), Long.parseLong(String.valueOf(decodedJWT.getExpiresAt().getTime())), TimeUnit.MILLISECONDS); | ||
|
||
public void setValues(Authentication authentication, String refreshToken,Long time) { | ||
ValueOperations<String, Object> values = redisTemplate.opsForValue(); | ||
values.set(authentication.getName(),refreshToken,time , TimeUnit.MILLISECONDS); | ||
} | ||
|
||
public String getValues(String key) { | ||
ValueOperations<String, Object> values = redisTemplate.opsForValue(); | ||
return (String) values.get(key); | ||
} | ||
|
||
public void deleteValues(String key) { | ||
redisTemplate.delete(key); | ||
} | ||
} |
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
Oops, something went wrong.