Commit a40fd26255e8825bb180f68db5907066a4c75b7d

Authored by zhangdaiscott
1 parent 7f6e204c

在线切换部门,用户缓存信息未变更 issues/I1X4DT

jeecg-boot/jeecg-boot-base-common/src/main/java/org/jeecg/common/constant/CacheConstant.java
... ... @@ -8,11 +8,6 @@ package org.jeecg.common.constant;
8 8 public interface CacheConstant {
9 9  
10 10 /**
11   - * 缓存用户jwt
12   - */
13   - public static final String SYS_USERS_CACHE_JWT = "sys:cache:user:jwt";
14   -
15   - /**
16 11 * 字典信息缓存
17 12 */
18 13 public static final String SYS_DICT_CACHE = "sys:cache:dict";
... ...
jeecg-boot/jeecg-boot-base-common/src/main/java/org/jeecg/config/shiro/ShiroRealm.java
... ... @@ -114,14 +114,7 @@ public class ShiroRealm extends AuthorizingRealm {
114 114  
115 115 // 查询用户信息
116 116 log.debug("———校验token是否有效————checkUserTokenIsEffect——————— "+ token);
117   - LoginUser loginUser = (LoginUser) redisUtil.get(CacheConstant.SYS_USERS_CACHE_JWT+":"+token);
118   - //TODO 当前写法导致两个小时操作中token过期
119   - //如果redis缓存用户信息为空,则通过接口获取用户信息,避免超过两个小时操作中token过期
120   - if(loginUser==null){
121   - loginUser = commonAPI.getUserByName(username);
122   - //密码二次加密,因为存于redis会泄露
123   - loginUser.setPassword(SecureUtil.md5(loginUser.getPassword()));
124   - }
  117 + LoginUser loginUser = commonAPI.getUserByName(username);
125 118 if (loginUser == null) {
126 119 throw new AuthenticationException("用户不存在!");
127 120 }
... ...
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/cas/controller/CasClientController.java
... ... @@ -87,14 +87,6 @@ public class CasClientController {
87 87 redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
88 88 redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
89 89  
90   - //update-begin-author:taoyan date:20200812 for:登录缓存用户信息
91   - LoginUser vo = new LoginUser();
92   - BeanUtils.copyProperties(sysUser,vo);
93   - vo.setPassword(SecureUtil.md5(sysUser.getPassword()));
94   - redisUtil.set(CacheConstant.SYS_USERS_CACHE_JWT +":" +token, vo);
95   - redisUtil.expire(CacheConstant.SYS_USERS_CACHE_JWT +":" +token, JwtUtil.EXPIRE_TIME*2 / 1000);
96   - //update-end-author:taoyan date:20200812 for:登录缓存用户信息
97   -
98 90 //获取用户部门信息
99 91 JSONObject obj = new JSONObject();
100 92 List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
... ...
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java
... ... @@ -356,20 +356,11 @@ public class LoginController {
356 356 String syspassword = sysUser.getPassword();
357 357 String username = sysUser.getUsername();
358 358 // 生成token
359   - String token = JwtUtil.sign(username, SecureUtil.md5(syspassword));
  359 + String token = JwtUtil.sign(username, syspassword);
360 360 // 设置token缓存有效时间
361 361 redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
362 362 redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
363 363  
364   - //update-begin-author:taoyan date:20200812 for:登录缓存用户信息
365   - LoginUser vo = new LoginUser();
366   - BeanUtils.copyProperties(sysUser,vo);
367   - //密码二次加密,因为存于redis会泄露
368   - vo.setPassword(SecureUtil.md5(sysUser.getPassword()));
369   - redisUtil.set(CacheConstant.SYS_USERS_CACHE_JWT +":" +token, vo);
370   - redisUtil.expire(CacheConstant.SYS_USERS_CACHE_JWT +":" +token, JwtUtil.EXPIRE_TIME*2 / 1000);
371   - //update-end-author:taoyan date:20200812 for:登录缓存用户信息
372   -
373 364 // 获取用户部门信息
374 365 JSONObject obj = new JSONObject();
375 366 List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
... ... @@ -484,14 +475,6 @@ public class LoginController {
484 475 redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
485 476 redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
486 477  
487   - //update-begin-author:taoyan date:20200812 for:登录缓存用户信息
488   - LoginUser vo = new LoginUser();
489   - BeanUtils.copyProperties(sysUser,vo);
490   - vo.setPassword(SecureUtil.md5(sysUser.getPassword()));
491   - redisUtil.set(CacheConstant.SYS_USERS_CACHE_JWT +":" +token, vo);
492   - redisUtil.expire(CacheConstant.SYS_USERS_CACHE_JWT +":" +token, JwtUtil.EXPIRE_TIME*2 / 1000);
493   - //update-end-author:taoyan date:20200812 for:登录缓存用户信息
494   -
495 478 //token 信息
496 479 obj.put("token", token);
497 480 result.setResult(obj);
... ...
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/ThirdLoginController.java
... ... @@ -109,14 +109,6 @@ public class ThirdLoginController {
109 109 // 设置超时时间
110 110 redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
111 111  
112   - //update-begin-author:taoyan date:20200812 for:登录缓存用户信息
113   - LoginUser redisUser = new LoginUser();
114   - BeanUtils.copyProperties(user, redisUser);
115   - redisUser.setPassword(SecureUtil.md5(user.getPassword()));
116   - redisUtil.set(CacheConstant.SYS_USERS_CACHE_JWT +":" +token, redisUser);
117   - redisUtil.expire(CacheConstant.SYS_USERS_CACHE_JWT +":" +token, JwtUtil.EXPIRE_TIME*2 / 1000);
118   - //update-end-author:taoyan date:20200812 for:登录缓存用户信息
119   -
120 112 modelMap.addAttribute("token", token);
121 113 //update-begin--Author:wangshuai Date:20200729 for:接口在签名校验失败时返回失败的标识码 issues#1441--------------------
122 114 }else{
... ...