Commit 556ce5c3 by 罗承锋

优化垂直鉴权

parent 15496373
...@@ -65,10 +65,11 @@ public class AuthIntercept extends HandlerInterceptorAdapter { ...@@ -65,10 +65,11 @@ public class AuthIntercept extends HandlerInterceptorAdapter {
String key = AUTH_REDIS_PREFIX + StringUtils.join(roleList.toArray(), ","); String key = AUTH_REDIS_PREFIX + StringUtils.join(roleList.toArray(), ",");
String securityKey = AUTH_REDIS_SECURITY + security; String securityKey = AUTH_REDIS_SECURITY + security;
Boolean aBoolean = stringRedisTemplate.opsForValue().setIfAbsent(securityKey, "1");
String securityValue = stringRedisTemplate.opsForValue().get(securityKey); if (!aBoolean) {
if (StringUtils.isNotBlank(securityValue)) {
return false; return false;
}else {
stringRedisTemplate.opsForValue().set(securityKey, "1", 1, TimeUnit.DAYS);
} }
ResponseData<String> stringResponseData = LoginUtils.pwdDecrypt(security); ResponseData<String> stringResponseData = LoginUtils.pwdDecrypt(security);
...@@ -102,9 +103,6 @@ public class AuthIntercept extends HandlerInterceptorAdapter { ...@@ -102,9 +103,6 @@ public class AuthIntercept extends HandlerInterceptorAdapter {
log.info(menu.getUrl()); log.info(menu.getUrl());
if (StringUtils.equals(menu.getUrl(), data)) { if (StringUtils.equals(menu.getUrl(), data)) {
log.info("获取到相同的菜单"); log.info("获取到相同的菜单");
stringRedisTemplate.opsForValue().set(securityKey, "1", 1, TimeUnit.HOURS);
return true; return true;
} }
} }
......
...@@ -72,9 +72,11 @@ public class AuthIntercept extends HandlerInterceptorAdapter { ...@@ -72,9 +72,11 @@ public class AuthIntercept extends HandlerInterceptorAdapter {
String securityKey = AUTH_REDIS_SECURITY + security; String securityKey = AUTH_REDIS_SECURITY + security;
String securityValue = stringRedisTemplate.opsForValue().get(securityKey); Boolean aBoolean = stringRedisTemplate.opsForValue().setIfAbsent(securityKey, "1");
if (StringUtils.isNotBlank(securityValue)) { if (!aBoolean) {
return false; return false;
}else {
stringRedisTemplate.opsForValue().set(securityKey, "1", 1, TimeUnit.DAYS);
} }
ResponseData<String> stringResponseData = LoginUtils.pwdDecrypt(security); ResponseData<String> stringResponseData = LoginUtils.pwdDecrypt(security);
...@@ -108,9 +110,6 @@ public class AuthIntercept extends HandlerInterceptorAdapter { ...@@ -108,9 +110,6 @@ public class AuthIntercept extends HandlerInterceptorAdapter {
log.info(menu.getUrl()); log.info(menu.getUrl());
if (StringUtils.equals(menu.getUrl(), data)) { if (StringUtils.equals(menu.getUrl(), data)) {
log.info("获取到相同的菜单"); log.info("获取到相同的菜单");
stringRedisTemplate.opsForValue().set(securityKey, "1", 1, TimeUnit.HOURS);
return true; return true;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment