Commit b1829ee8 authored by 李健华's avatar 李健华

修改交换token验证

parent 3a676134
...@@ -550,20 +550,27 @@ public class UserController implements IBaseController { ...@@ -550,20 +550,27 @@ public class UserController implements IBaseController {
headers.put("qg-tenant-id", tenantId.toString()); headers.put("qg-tenant-id", tenantId.toString());
parameters.put("token", token); parameters.put("token", token);
String resultStr = httpService.post(userHost + "/api/finance-gateway/finance-user/finance/tokenExchange", headers, parameters); try {
// 如果有返回值 String resultStr = httpService.post(userHost + "/api/finance-gateway/finance-user/shop/tokenExchange", headers, parameters);
if (resultStr != null) {
JsonResult<TokenExchange> tokenExchangeResult = JSONObject.parseObject(resultStr, new TypeReference<JsonResult<TokenExchange>>(){}); JsonResult<TokenExchange> tokenExchangeResult = JSONObject.parseObject(resultStr, new TypeReference<JsonResult<TokenExchange>>(){});
// 如果有返回值
TokenExchange tokenExchange = tokenExchangeResult.getData(); TokenExchange tokenExchange = tokenExchangeResult.getData();
SessionValue sessionValue = new SessionValue(); if (tokenExchange != null) {
User user = userService.findById(tokenExchange.getUserId()); SessionValue sessionValue = new SessionValue();
LoginProperties loginProperties = JSONObject.parseObject(tokenExchange.getLoginProperties(), LoginProperties.class); User user = userService.findById(tokenExchange.getUserId());
if (user != null) {
// 根据返回值生成token, 返回值包含user:session:token的值 LoginProperties loginProperties = JSONObject.parseObject(tokenExchange.getLoginProperties(), LoginProperties.class);
sessionValue.setUser(user);
sessionValue.setLoginProperties(loginProperties); // 根据返回值生成token, 返回值包含user:session:token的值
sessionService.persistSessionExchange(token, sessionValue); sessionValue.setUser(user);
sessionValue.setLoginProperties(loginProperties);
sessionService.persistSessionExchange(token, sessionValue);
}
}
} catch (Exception e) {
e.printStackTrace();
log.error("请求金融卡包网关出错--{}", e.getMessage());
} }
} }
......
...@@ -14,6 +14,7 @@ import cn.quantgroup.xyqb.util.TenantUtil; ...@@ -14,6 +14,7 @@ import cn.quantgroup.xyqb.util.TenantUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Caching; import org.springframework.cache.annotation.Caching;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
...@@ -37,6 +38,9 @@ public class SessionServiceImpl implements ISessionService { ...@@ -37,6 +38,9 @@ public class SessionServiceImpl implements ISessionService {
@Resource @Resource
private RedisTemplate<String, String> stringRedisTemplate; private RedisTemplate<String, String> stringRedisTemplate;
@Value("${token.prefix}")
private String prefix;
/** /**
* 更新session * 更新session
* 用户信息存在,更新session中的最后访问时间,重新写入缓存. * 用户信息存在,更新session中的最后访问时间,重新写入缓存.
...@@ -123,7 +127,7 @@ public class SessionServiceImpl implements ISessionService { ...@@ -123,7 +127,7 @@ public class SessionServiceImpl implements ISessionService {
Timestamp now = new Timestamp(System.currentTimeMillis()); Timestamp now = new Timestamp(System.currentTimeMillis());
SessionStruct sessionStruct = new SessionStruct(); SessionStruct sessionStruct = new SessionStruct();
SessionValue sessionValue = new SessionValue(); SessionValue sessionValue = new SessionValue();
sessionStruct.setSid("yxm-" + UUID.randomUUID().toString()); sessionStruct.setSid(prefix + UUID.randomUUID().toString());
sessionValue.setCreatedAt(now); sessionValue.setCreatedAt(now);
sessionValue.setLastAccessTime(now); sessionValue.setLastAccessTime(now);
sessionValue.setUser(user); sessionValue.setUser(user);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment