Selaa lähdekoodia

恢复请求刷新token有效期的问题,防止操作过程中过期

ZhangWenQiang 5 vuotta sitten
vanhempi
commit
694542f078

+ 9 - 9
happy-boot-module-system/src/main/java/org/jeecg/modules/shiro/authc/ShiroRealm.java

@@ -52,7 +52,7 @@ public class ShiroRealm extends AuthorizingRealm {
 
 	/**
 	 * 功能: 获取用户权限信息,包括角色以及权限。只有当触发检测用户权限时才会调用此方法,例如checkRole,checkPermission
-	 * 
+	 *
 	 * @param token token
 	 * @return AuthorizationInfo 权限信息
 	 */
@@ -79,7 +79,7 @@ public class ShiroRealm extends AuthorizingRealm {
 
 	/**
 	 * 功能: 用来进行身份认证,也就是说验证用户输入的账号和密码是否正确,获取身份验证信息,错误抛出异常
-	 * 
+	 *
 	 * @param authenticationToken 用户身份信息 token
 	 * @return 返回封装了用户信息的 AuthenticationInfo 实例
 	 */
@@ -97,7 +97,7 @@ public class ShiroRealm extends AuthorizingRealm {
 
 	/**
 	 * 校验token的有效性
-	 * 
+	 *
 	 * @param token
 	 */
 	public LoginUser checkUserTokenIsEffect(String token) throws AuthenticationException {
@@ -137,7 +137,7 @@ public class ShiroRealm extends AuthorizingRealm {
 	 * 6、每次当返回为true情况下,都会给Response的Header中设置Authorization,该Authorization映射的v为cache对应的v值。
 	 * 7、注:当前端接收到Response的Header中的Authorization值会存储起来,作为以后请求token使用
 	 * 参考方案:https://blog.csdn.net/qq394829044/article/details/82763936
-	 * 
+	 *
 	 * @param userName
 	 * @param passWord
 	 * @return
@@ -153,11 +153,11 @@ public class ShiroRealm extends AuthorizingRealm {
 				redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 3 / 1000);
 			}
 			//update-begin--Author:scott  Date:20191005  for:解决每次请求,都重写redis中 token缓存问题
-//			else {
-//				// 设置超时时间
-//				redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, cacheToken);
-//				redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
-//			}
+			else {
+				// 设置超时时间
+				redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, cacheToken);
+				redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 3 / 1000);
+			}
 			//update-end--Author:scott  Date:20191005   for:解决每次请求,都重写redis中 token缓存问题
 			return true;
 		}