refactor(jwt配置): 优化名称

master
wayn 5 years ago
parent c33d9ad94c
commit 4bb46bcb98

@ -21,10 +21,15 @@ public class SysConstants {
public static final String LOGIN_TOKEN_KEY = "login_tokens:";
/**
*
* key
*/
public static final String SIGN_KEY = "login_user_key";
/**
*
*/
public static final String TOKEN_PREFIX = "Bearer ";
/**
* M C F
*/

@ -43,8 +43,7 @@ public class TokenService {
// 解析对应的权限以及用户信息
String sign = decodedJWT.getClaim(SysConstants.SIGN_KEY).asString();
String userKey = getTokenKey(sign);
LoginUserDetail user = redisCache.getCacheObject(userKey);
return user;
return redisCache.getCacheObject(userKey);
}
return null;
}
@ -82,18 +81,22 @@ public class TokenService {
/**
* token
*
* @param request
* @param request
* @return token
*/
private String getToken(HttpServletRequest request) {
return request.getHeader(header);
String token = request.getHeader(header);
if (StringUtils.isNotEmpty(token) && token.startsWith(SysConstants.TOKEN_PREFIX)) {
token = token.replace(SysConstants.TOKEN_PREFIX, "");
}
return token;
}
/**
* key
*
* @param sign
* @return
* @param sign
* @return tokenkey
*/
private String getTokenKey(String sign) {
return SysConstants.LOGIN_TOKEN_KEY + sign;

Loading…
Cancel
Save