ADD COMMENT

This commit is contained in:
王瑜 2021-01-25 13:44:17 +08:00
parent 925cc2945f
commit 933f59f132
1 changed files with 4 additions and 1 deletions

View File

@ -39,6 +39,9 @@ import java.util.function.Supplier;
@Service @Service
public class MongoUserDetailsServiceImpl implements MongoUserDetailsService { public class MongoUserDetailsServiceImpl implements MongoUserDetailsService {
// 登录失败限制
private static final int ERROR_LIMIT = 5;
// 存储用户校验规则的map // 存储用户校验规则的map
private static final Map<Function<User, Boolean>, Supplier<AuthenticationException>> checkMap; private static final Map<Function<User, Boolean>, Supplier<AuthenticationException>> checkMap;
@ -163,7 +166,7 @@ public class MongoUserDetailsServiceImpl implements MongoUserDetailsService {
User updating = new User(); User updating = new User();
updating.setId(user.getId()); updating.setId(user.getId());
updating.setErrorCount(user.getErrorCount() + 1); updating.setErrorCount(user.getErrorCount() + 1);
if (updating.getErrorCount() >= 5) { if (updating.getErrorCount() >= ERROR_LIMIT) {
updating.setStatus(UserStatus.LOCKED); updating.setStatus(UserStatus.LOCKED);
} }
return userService.updateSelectiveById(updating); return userService.updateSelectiveById(updating);