提交 df8944be 作者: han

bug

上级 2e216e24
......@@ -43,6 +43,7 @@ public class AuthHandler {
String token = JwtUtil.createJwt(map);
LoginSuccessDTO loginSuccessDTO = LoginSuccessDTO.builder().token(token).openId(userAccountVO.getOpenId()).userAccountId(userAccountVO.getId()).uid(userAccountVO.getId() + "")
.userName(userAccountVO.getUserName()).nickName(userAccountVO.getNickName()).phoneNum(userAccountVO.getPhoneNum()).portType(UserTypeEnums.APP.getType()).build();
stringRedisTemplate.setValueSerializer(RedisSerializer.json());
stringRedisTemplate.opsForValue().set(
token, new Gson().toJson(loginSuccessDTO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
......@@ -58,6 +59,7 @@ public class AuthHandler {
String token = JwtUtil.createJwt(map);
LoginSuccessDTO loginSuccessDTO = LoginSuccessDTO.builder().token(token).userAccountId(userAccountVO.getId())
.phoneNum(userAccountVO.getPhoneNum()).portType(UserTypeEnums.APP.getType()).build();
stringRedisTemplate.setValueSerializer(RedisSerializer.json());
stringRedisTemplate.opsForValue().set(
token, new Gson().toJson(loginSuccessDTO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
......@@ -80,6 +82,7 @@ public class AuthHandler {
.userName(user.getUserName()).nickName(user.getUserName()).phoneNum(user.getPhoneNum()).portType(UserTypeEnums.PC.getType())
.companyInfoVO(companyInfoVO == null ? null : companyInfoVO)
.roleInfo(roleInfoDO.buildRoleInfoDTO()).build();
stringRedisTemplate.setValueSerializer(RedisSerializer.json());
stringRedisTemplate.opsForValue().set(
token, new Gson().toJson(loginSuccessDTO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
......
......@@ -43,6 +43,7 @@ public class TokenCheckHandleInterceptor implements HandlerInterceptor {
exceptionProcess(response);
return false;
}
stringRedisTemplate.setValueSerializer(RedisSerializer.json());
String tokenJson = stringRedisTemplate.opsForValue().get(token);
if (StringUtils.isBlank(tokenJson)) {
exceptionProcess(response);
......
......@@ -12,6 +12,7 @@ import io.jsonwebtoken.Claims;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
......@@ -54,6 +55,7 @@ public abstract class BaseController {
if (StringUtils.isBlank(token)){
throw new BizException(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR);
}
stringRedisTemplate.setValueSerializer(RedisSerializer.json());
String json = stringRedisTemplate.opsForValue().get(token);
if (StringUtils.isBlank(json)){
throw new BizException(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论