소스 검색

修改密码输入错误次数和锁定时间为参数配置,而不是在配置文件里配置。

wukai 2 년 전
부모
커밋
9051d9f12b
1개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 6 6
      doc-framework/src/main/java/com/doc/framework/web/service/SysPasswordService.java

+ 6 - 6
doc-framework/src/main/java/com/doc/framework/web/service/SysPasswordService.java

@@ -11,7 +11,7 @@ import com.doc.common.utils.SecurityUtils;
 import com.doc.framework.manager.AsyncManager;
 import com.doc.framework.manager.factory.AsyncFactory;
 import com.doc.framework.security.context.AuthenticationContextHolder;
-import org.springframework.beans.factory.annotation.Value;
+import com.doc.system.service.ISysConfigService;
 import org.springframework.security.core.Authentication;
 import org.springframework.stereotype.Component;
 
@@ -27,12 +27,9 @@ import java.util.concurrent.TimeUnit;
 public class SysPasswordService {
     @Resource
     private RedisCache redisCache;
+    @Resource
+    private ISysConfigService configService;
 
-    @Value(value = "${user.password.maxRetryCount}")
-    private int maxRetryCount;
-
-    @Value(value = "${user.password.lockTime}")
-    private int lockTime;
 
     /**
      * 登录账户密码错误次数缓存键名
@@ -45,6 +42,9 @@ public class SysPasswordService {
     }
 
     public void validate(SysUser user) {
+        int maxRetryCount = Integer.parseInt(configService.selectConfigByKey("user.password.maxRetryCount"));
+        int lockTime = Integer.parseInt(configService.selectConfigByKey("user.password.lockTime"));
+
         Authentication usernamePasswordAuthenticationToken = AuthenticationContextHolder.getContext();
         String username = usernamePasswordAuthenticationToken.getName();
         String password = usernamePasswordAuthenticationToken.getCredentials().toString();