参数名变更
This commit is contained in:
parent
41b9c2387e
commit
5ac9c7dc71
@ -1,7 +1,6 @@
|
||||
package com.rymcu.vertical.jwt.service;
|
||||
|
||||
|
||||
import com.rymcu.vertical.core.service.redis.RedisService;
|
||||
import com.rymcu.vertical.jwt.def.JwtConstants;
|
||||
import com.rymcu.vertical.jwt.model.TokenModel;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
@ -22,12 +21,11 @@ import java.util.concurrent.TimeUnit;
|
||||
public class RedisTokenManager implements TokenManager {
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 生成TOKEN
|
||||
*/
|
||||
@Override
|
||||
public String createToken(String id) {
|
||||
//使用uuid作为源token
|
||||
String token = Jwts.builder().setId(id).setSubject(id).setIssuedAt(new Date()).signWith(SignatureAlgorithm.HS256, JwtConstants.JWT_SECRET).compact();
|
||||
@ -36,10 +34,12 @@ public class RedisTokenManager implements TokenManager {
|
||||
return token;
|
||||
}
|
||||
|
||||
public TokenModel getToken(String token, String userid) {
|
||||
return new TokenModel(userid, token);
|
||||
@Override
|
||||
public TokenModel getToken(String token, String account) {
|
||||
return new TokenModel(account, token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkToken(TokenModel model) {
|
||||
if (model == null) {
|
||||
return false;
|
||||
@ -53,7 +53,8 @@ public class RedisTokenManager implements TokenManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void deleteToken(String username) {
|
||||
redisTemplate.delete(username);
|
||||
@Override
|
||||
public void deleteToken(String account) {
|
||||
redisTemplate.delete(account);
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ public interface TokenManager {
|
||||
* 从字符串中解析token
|
||||
* @return
|
||||
*/
|
||||
public TokenModel getToken(String token, String userid);
|
||||
public TokenModel getToken(String token, String account);
|
||||
|
||||
/**
|
||||
* 清除token
|
||||
* @param username 登录用户账号
|
||||
* @param account 登录用户账号
|
||||
*/
|
||||
public void deleteToken(String username);
|
||||
public void deleteToken(String account);
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user