|
|
@ -192,6 +192,39 @@ public class ShiroRealm extends AuthorizingRealm { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 校验token的有效性 |
|
|
|
* |
|
|
|
* @param token |
|
|
|
*/ |
|
|
|
public HanHaiMember checkUserTokenIsEffectHanHaiOpenId(String token) throws AuthenticationException { |
|
|
|
Result result = new Result(); |
|
|
|
// 解密获得username,用于和数据库进行对比 |
|
|
|
String openid = JwtUtil.getUsername(token); |
|
|
|
if (openid == null) { |
|
|
|
throw new AuthenticationException("token非法无效!"); |
|
|
|
} |
|
|
|
|
|
|
|
// 查询用户信息 |
|
|
|
log.debug("———校验token是否有效————checkUserTokenIsEffect——————— "+ token); |
|
|
|
HanHaiMember user = commonApi.getUserByNameHanHaiXcxOpenId(openid); |
|
|
|
if (user == null || user.getAppletOpenid() == null) { |
|
|
|
throw new AuthenticationException("用户不存在!"); |
|
|
|
} |
|
|
|
// // 判断用户状态 |
|
|
|
// if (user.getDeleteFlag().equals("Y")) { |
|
|
|
// throw new AuthenticationException("账号已被注销,请联系管理员!"); |
|
|
|
// } |
|
|
|
// 校验token是否超时失效 & 或者账号密码是否错误 |
|
|
|
if (!jwtTokenRefresh(token, openid, openid)) { |
|
|
|
throw new JeecgBoot401Exception(CommonConstant.TOKEN_IS_INVALID_MSG); |
|
|
|
} |
|
|
|
return user; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* JWTToken刷新生命周期 (实现: 用户在线操作不掉线功能) |
|
|
|
* 1、登录成功后将用户的JWT生成的Token作为k、v存储到cache缓存里面(这时候k、v值一样),缓存有效期设置为Jwt有效时间的2倍 |
|
|
|