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

修改交换token验证

parent 3a676134
......@@ -550,21 +550,28 @@ public class UserController implements IBaseController {
headers.put("qg-tenant-id", tenantId.toString());
parameters.put("token", token);
String resultStr = httpService.post(userHost + "/api/finance-gateway/finance-user/finance/tokenExchange", headers, parameters);
// 如果有返回值
if (resultStr != null) {
try {
String resultStr = httpService.post(userHost + "/api/finance-gateway/finance-user/shop/tokenExchange", headers, parameters);
JsonResult<TokenExchange> tokenExchangeResult = JSONObject.parseObject(resultStr, new TypeReference<JsonResult<TokenExchange>>(){});
// 如果有返回值
TokenExchange tokenExchange = tokenExchangeResult.getData();
if (tokenExchange != null) {
SessionValue sessionValue = new SessionValue();
User user = userService.findById(tokenExchange.getUserId());
if (user != null) {
LoginProperties loginProperties = JSONObject.parseObject(tokenExchange.getLoginProperties(), LoginProperties.class);
// 根据返回值生成token, 返回值包含user:session:token的值
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;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Caching;
import org.springframework.data.redis.core.RedisTemplate;
......@@ -37,6 +38,9 @@ public class SessionServiceImpl implements ISessionService {
@Resource
private RedisTemplate<String, String> stringRedisTemplate;
@Value("${token.prefix}")
private String prefix;
/**
* 更新session
* 用户信息存在,更新session中的最后访问时间,重新写入缓存.
......@@ -123,7 +127,7 @@ public class SessionServiceImpl implements ISessionService {
Timestamp now = new Timestamp(System.currentTimeMillis());
SessionStruct sessionStruct = new SessionStruct();
SessionValue sessionValue = new SessionValue();
sessionStruct.setSid("yxm-" + UUID.randomUUID().toString());
sessionStruct.setSid(prefix + UUID.randomUUID().toString());
sessionValue.setCreatedAt(now);
sessionValue.setLastAccessTime(now);
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