| | |
| | | if(UserStatusEnum.DISABLE.getCode().equals(sysUser.getStatus())){ |
| | | throw new AuthenticationException("用户已被停用"); |
| | | } |
| | | if(UserIdentityEnum.AGENCY.getCode().equals(sysUser.getIdentity())){ |
| | | if(!ApproveStatusEnum.APPROVED.getCode().equals(sysUser.getState())){ |
| | | throw new AuthenticationException("机构账户审批还未通过"); |
| | | } |
| | | } |
| | | // if(UserIdentityEnum.AGENCY.getCode().equals(sysUser.getIdentity())){ |
| | | // if(!ApproveStatusEnum.APPROVED.getCode().equals(sysUser.getState())){ |
| | | // throw new AuthenticationException("机构账户审批还未通过"); |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | public SysUser validJwtToken(String jwtToken){ |
| | |
| | | throw new AuthenticationException("token非法无效!"); |
| | | } |
| | | if(!jwtTokenRefresh(jwtToken,username,sysUser.getPassword(),identity)){ |
| | | throw new AuthenticationException("Token已失效,请重新登录!"); |
| | | throw new AuthenticationException("您的账号登录过期,请重新登录!"); |
| | | } |
| | | // setRolePermission(sysUser); |
| | | return sysUser; |
| | |
| | | */ |
| | | public boolean jwtTokenRefresh(String jwtToken, String username, String passWord, Integer identity){ |
| | | String tokenKey=redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN+":"+JwtTokenUtil.md5Encode(jwtToken)); |
| | | String userKey=redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN+":"+username+"_"+identity); |
| | | // String userKey=redisUtils.generateKey(CacheConstant.SYS_USER_TOKEN+":"+username+"_"+identity); |
| | | String cacheToken= (String) redisUtils.get(tokenKey); |
| | | if(StringUtils.isNotEmpty(cacheToken)){ |
| | | // 校验token有效性 |
| | | if(!JwtTokenUtil.isNeedUpdate(cacheToken,username,passWord,identity)){ |
| | | String newToken=JwtTokenUtil.sign(username,passWord,identity); |
| | | // 设置超时时间 |
| | | redisUtils.set(tokenKey,newToken); |
| | | redisUtils.expire(tokenKey,JwtTokenUtil.EXPIRATION*2/1000); |
| | | redisUtils.expire(userKey,(JwtTokenUtil.EXPIRATION*2/1000)+2); |
| | | redisUtils.set(tokenKey,newToken,JwtTokenUtil.EXPIRATION*2/1000); |
| | | // redisUtils.expire(userKey,(JwtTokenUtil.EXPIRATION*2/1000)+2); |
| | | } |
| | | return true; |
| | | } |