文件生成补充
This commit is contained in:
@@ -19,13 +19,13 @@ public class JwtTokenProvider {
|
||||
|
||||
private final JwtProperties jwtProperties;
|
||||
|
||||
public String generateAccessToken(Long userId, String role) {
|
||||
public String generateAccessToken(Long userId, Integer role) {
|
||||
Date now = new Date();
|
||||
Date expiryDate = new Date(now.getTime() + jwtProperties.getAccessTokenExpire() * 1000);
|
||||
|
||||
return Jwts.builder()
|
||||
.subject(String.valueOf(userId))
|
||||
.claim("role", role)
|
||||
.claim("role", String.valueOf(role))
|
||||
.issuedAt(now)
|
||||
.expiration(expiryDate)
|
||||
.signWith(jwtProperties.getSigningKey())
|
||||
|
||||
@@ -40,4 +40,8 @@ public class TokenBlacklistService {
|
||||
String key = SecurityConstants.REFRESH_TOKEN_KEY + userId;
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
public void addToBlacklist(String token) {
|
||||
blacklistAccessToken(token, 7200);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user