[AppleScript] 纯文本查看 复制代码
//从redis查询令牌
public AuthToken getUserToken(String token){
String userToken = "user_token:"+token;
String userTokenString = stringRedisTemplate.opsForValue().get(userToken);
if(userToken!=null){
AuthToken authToken = null;
try {
authToken = JSON.parseObject(userTokenString, AuthToken.class);
} catch (Exception e) {
LOGGER.error("getUserToken from redis and execute JSON.parseObject error {}",e.getMessage());
e.printStackTrace();
}
return authToken;
}
return null;
}
[AppleScript] 纯文本查看 复制代码
String access_token = getTokenFormCookie();
//根据令牌从redis查询jwt
AuthToken authToken = authService.getUserToken(access_token);
if(authToken == null){
return new JwtResult(CommonCode.FAIL,null);
}
return new JwtResult(CommonCode.SUCCESS,authToken.getJwt_token());
}
//从cookie中读取访问令牌
private String getTokenFormCookie(){
Map<String, String> cookieMap = CookieUtil.readCookie(request, "uid");
String access_token = cookieMap.get("uid");
return access_token;
}