Commit a40fd26255e8825bb180f68db5907066a4c75b7d
1 parent
7f6e204c
在线切换部门,用户缓存信息未变更 issues/I1X4DT
Showing
5 changed files
with
2 additions
and
47 deletions
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,11 +8,6 @@ package org.jeecg.common.constant; | ||
8 | public interface CacheConstant { | 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 | public static final String SYS_DICT_CACHE = "sys:cache:dict"; | 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,14 +114,7 @@ public class ShiroRealm extends AuthorizingRealm { | ||
114 | 114 | ||
115 | // 查询用户信息 | 115 | // 查询用户信息 |
116 | log.debug("———校验token是否有效————checkUserTokenIsEffect——————— "+ token); | 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 | if (loginUser == null) { | 118 | if (loginUser == null) { |
126 | throw new AuthenticationException("用户不存在!"); | 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,14 +87,6 @@ public class CasClientController { | ||
87 | redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token); | 87 | redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token); |
88 | redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000); | 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 | JSONObject obj = new JSONObject(); | 91 | JSONObject obj = new JSONObject(); |
100 | List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId()); | 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,20 +356,11 @@ public class LoginController { | ||
356 | String syspassword = sysUser.getPassword(); | 356 | String syspassword = sysUser.getPassword(); |
357 | String username = sysUser.getUsername(); | 357 | String username = sysUser.getUsername(); |
358 | // 生成token | 358 | // 生成token |
359 | - String token = JwtUtil.sign(username, SecureUtil.md5(syspassword)); | 359 | + String token = JwtUtil.sign(username, syspassword); |
360 | // 设置token缓存有效时间 | 360 | // 设置token缓存有效时间 |
361 | redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token); | 361 | redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token); |
362 | redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000); | 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 | JSONObject obj = new JSONObject(); | 365 | JSONObject obj = new JSONObject(); |
375 | List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId()); | 366 | List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId()); |
@@ -484,14 +475,6 @@ public class LoginController { | @@ -484,14 +475,6 @@ public class LoginController { | ||
484 | redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token); | 475 | redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token); |
485 | redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000); | 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 | //token 信息 | 478 | //token 信息 |
496 | obj.put("token", token); | 479 | obj.put("token", token); |
497 | result.setResult(obj); | 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,14 +109,6 @@ public class ThirdLoginController { | ||
109 | // 设置超时时间 | 109 | // 设置超时时间 |
110 | redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000); | 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 | modelMap.addAttribute("token", token); | 112 | modelMap.addAttribute("token", token); |
121 | //update-begin--Author:wangshuai Date:20200729 for:接口在签名校验失败时返回失败的标识码 issues#1441-------------------- | 113 | //update-begin--Author:wangshuai Date:20200729 for:接口在签名校验失败时返回失败的标识码 issues#1441-------------------- |
122 | }else{ | 114 | }else{ |