bug修复+代码调整+日志优化
This commit is contained in:
@@ -24,7 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.constants.ConstsRoles;
|
||||
import org.dromara.maxkey.constants.ConstsStatus;
|
||||
@@ -88,7 +88,7 @@ public class LoginRepository {
|
||||
listUserInfo = findByUsernameOrMobileOrEmail(username,password);
|
||||
}
|
||||
_logger.debug("load UserInfo : {}" , listUserInfo);
|
||||
return (ObjectUtils.isNotEmpty(listUserInfo))? listUserInfo.get(0) : null;
|
||||
return (CollectionUtils.isNotEmpty(listUserInfo) ? listUserInfo.get(0) : null);
|
||||
}
|
||||
|
||||
public List<UserInfo> findByUsername(String username, String password) {
|
||||
|
||||
@@ -217,13 +217,13 @@ public class PasswordPolicyValidator {
|
||||
*/
|
||||
public void lockUser(UserInfo userInfo) {
|
||||
try {
|
||||
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
||||
if(userInfo.getIsLocked() == ConstsStatus.ACTIVE) {
|
||||
jdbcTemplate.update(LOCK_USER_UPDATE_STATEMENT,
|
||||
new Object[] { ConstsStatus.LOCK, new Date(), userInfo.getId() },
|
||||
new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR });
|
||||
userInfo.setIsLocked(ConstsStatus.LOCK);
|
||||
}
|
||||
if (userInfo != null
|
||||
&& StringUtils.isNotEmpty(userInfo.getId())
|
||||
&& userInfo.getIsLocked() == ConstsStatus.ACTIVE) {
|
||||
jdbcTemplate.update(LOCK_USER_UPDATE_STATEMENT,
|
||||
new Object[] { ConstsStatus.LOCK, new Date(), userInfo.getId() },
|
||||
new int[] { Types.VARCHAR, Types.TIMESTAMP, Types.VARCHAR });
|
||||
userInfo.setIsLocked(ConstsStatus.LOCK);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
_logger.error("lockUser Exception",e);
|
||||
@@ -297,10 +297,8 @@ public class PasswordPolicyValidator {
|
||||
}
|
||||
|
||||
public void resetBadPasswordCount(UserInfo userInfo) {
|
||||
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId())) {
|
||||
if(userInfo.getBadPasswordCount()>0) {
|
||||
setBadPasswordCount(userInfo.getId(),0);
|
||||
}
|
||||
if (userInfo != null && StringUtils.isNotEmpty(userInfo.getId()) && userInfo.getBadPasswordCount()>0) {
|
||||
setBadPasswordCount(userInfo.getId(),0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,6 @@ public class InstitutionsService extends JpaService<Institutions>{
|
||||
|
||||
public Institutions findByDomain(String domain) {
|
||||
return getMapper().findByDomain(domain);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public class UserInfoService extends JpaService<UserInfo> {
|
||||
if(StringUtils.isNotBlank(changePassword.getPassword())) {
|
||||
String password = passwordEncoder.encode(changePassword.getPassword());
|
||||
changePassword.setDecipherable(PasswordReciprocal.getInstance().encode(changePassword.getPassword()));
|
||||
_logger.debug("decipherable : "+changePassword.getDecipherable());
|
||||
_logger.debug("decipherable : {}",changePassword.getDecipherable());
|
||||
changePassword.setPassword(password);
|
||||
changePassword.setPasswordLastSetTime(new Date());
|
||||
|
||||
@@ -303,10 +303,10 @@ public class UserInfoService extends JpaService<UserInfo> {
|
||||
*/
|
||||
public boolean changePassword(ChangePassword changePassword,boolean passwordPolicy) {
|
||||
try {
|
||||
_logger.debug("decipherable old : " + changePassword.getDecipherable());
|
||||
_logger.debug("decipherable new : " + PasswordReciprocal.getInstance().encode(changePassword.getDecipherable()));
|
||||
_logger.debug("decipherable old : {}" , changePassword.getDecipherable());
|
||||
_logger.debug("decipherable new : {}" , PasswordReciprocal.getInstance().encode(changePassword.getDecipherable()));
|
||||
|
||||
if (passwordPolicy && passwordPolicyValidator.validator(changePassword) == false) {
|
||||
if (passwordPolicy && !passwordPolicyValidator.validator(changePassword)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -333,10 +333,7 @@ public class UserInfoService extends JpaService<UserInfo> {
|
||||
if(changePassworded !=null && StringUtils.isNotBlank(changePassworded.getPassword())) {
|
||||
UserInfo loadUserInfo = findByUsername(changePassworded.getUsername());
|
||||
ChangePassword changePassword = new ChangePassword(loadUserInfo);
|
||||
provisionService.send(
|
||||
ProvisionTopic.PASSWORD_TOPIC,
|
||||
changePassword,
|
||||
ProvisionAct.PASSWORD);
|
||||
provisionService.send(ProvisionTopic.PASSWORD_TOPIC, changePassword, ProvisionAct.PASSWORD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user