Forráskód Böngészése

登录权限优化

yangbq 1 hónapja
szülő
commit
97e14f9f38

+ 1 - 6
project-common/src/main/java/com/project/common/core/redis/RedisCache.java

@@ -1,16 +1,11 @@
 package com.project.common.core.redis;
 
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.cache.Cache;
-import org.springframework.data.redis.core.BoundSetOperations;
-import org.springframework.data.redis.core.HashOperations;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
-import java.util.*;
+import java.util.Collection;
 import java.util.concurrent.TimeUnit;
 
 /**

+ 1 - 1
project-framework/src/main/java/com/project/framework/config/SecurityConfig.java

@@ -118,7 +118,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/login", "/register", "/captchaImage").anonymous()
                 // 静态资源,可匿名访问
                 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
-                .antMatchers( "/sxgw/**","/sxgw/**/**","/sxgw/**/**/**","/basics/**", "/basics/**/**", "/build/**", "/build/**/**","/employee/**", "/employee/**/**","/health/**", "/health/**/**","/post/**", "/post/**/**","/property/**", "/property/**/**","/smart/**", "/smart/**/**","/video/**", "/video/**/**").permitAll()
+                //.antMatchers( "/sxgw/**","/sxgw/**/**","/sxgw/**/**/**","/basics/**", "/basics/**/**", "/build/**", "/build/**/**","/employee/**", "/employee/**/**","/health/**", "/health/**/**","/post/**", "/post/**/**","/property/**", "/property/**/**","/smart/**", "/smart/**/**","/video/**", "/video/**/**").permitAll()
                 .antMatchers( "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()

+ 2 - 1
project-framework/src/main/java/com/project/framework/web/service/SysLoginService.java

@@ -85,7 +85,6 @@ public class SysLoginService {
             // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
             authentication = authenticationManager.authenticate(authenticationToken);
         } catch (Exception e) {
-            AuthenticationContextHolder.clearContext();
             if (e instanceof BadCredentialsException) {
                 AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
                 throw new UserPasswordNotMatchException();
@@ -93,6 +92,8 @@ public class SysLoginService {
                 AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
                 throw new ServiceException(e.getMessage());
             }
+        }finally {
+            AuthenticationContextHolder.clearContext();
         }
 
         AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));

+ 1 - 5
project-zcustom/src/main/java/com/project/zcustom/tools/LogisticsService.java

@@ -5,16 +5,14 @@ import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
 import com.project.common.utils.StringUtils;
 import com.project.common.utils.http.HttpUtils;
-//import com.project.zcustom.domain.addional.BizMetric;
 import com.project.zcustom.domain.addional.LargeAssetDirs;
 import com.project.zcustom.domain.addional.LargeLogistics;
 import com.project.zcustom.domain.basics.PlatAppOrg;
 import com.project.zcustom.domain.plat.AssetMonitoringResponse;
 import com.project.zcustom.domain.plat.PlatApiRecord;
 import com.project.zcustom.mapper.logistics.PlatAssetMapper;
-//import com.project.zcustom.service.logistics.IBizMetricService;
-import com.project.zcustom.service.service.basics.IPlatAppOrgService;
 import com.project.zcustom.service.plat.IPlatApiRecordService;
+import com.project.zcustom.service.service.basics.IPlatAppOrgService;
 import org.apache.commons.compress.utils.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -38,8 +36,6 @@ public class LogisticsService {
     private IPlatAppOrgService platAppOrgService;
     @Resource
     IPlatApiRecordService iPlatApiRecordService;
-//    @Resource
-//    private IBizMetricService bizMetricService;
 
 
     public void getLogisticsData(){