mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-06 17:08:29 +08:00
isUserExist
This commit is contained in:
parent
e56b239693
commit
1cc41d1d23
@ -209,10 +209,10 @@ public abstract class AbstractAuthenticationProvider {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean statusValid(LoginCredential loginCredential , UserInfo userInfo) {
|
protected boolean isUserExist(LoginCredential loginCredential , UserInfo userInfo) {
|
||||||
if (null == userInfo) {
|
if (null == userInfo) {
|
||||||
String i18nMessage = WebContext.getI18nValue("login.error.username");
|
String i18nMessage = WebContext.getI18nValue("login.error.username");
|
||||||
_logger.debug("login user " + loginCredential.getUsername() + " not in this System ." + i18nMessage);
|
_logger.debug("login user {} not in this System , message {} ." ,loginCredential.getUsername(), i18nMessage);
|
||||||
UserInfo loginUser = new UserInfo(loginCredential.getUsername());
|
UserInfo loginUser = new UserInfo(loginCredential.getUsername());
|
||||||
loginUser.setId(loginUser.generateId());
|
loginUser.setId(loginUser.generateId());
|
||||||
loginUser.setUsername(loginCredential.getUsername());
|
loginUser.setUsername(loginCredential.getUsername());
|
||||||
@ -225,26 +225,29 @@ public abstract class AbstractAuthenticationProvider {
|
|||||||
i18nMessage,
|
i18nMessage,
|
||||||
WebConstants.LOGIN_RESULT.USER_NOT_EXIST);
|
WebConstants.LOGIN_RESULT.USER_NOT_EXIST);
|
||||||
throw new BadCredentialsException(i18nMessage);
|
throw new BadCredentialsException(i18nMessage);
|
||||||
}else {
|
|
||||||
if(userInfo.getIsLocked()==ConstsStatus.LOCK) {
|
|
||||||
authenticationRealm.insertLoginHistory(
|
|
||||||
userInfo,
|
|
||||||
loginCredential.getAuthType(),
|
|
||||||
loginCredential.getProvider(),
|
|
||||||
loginCredential.getCode(),
|
|
||||||
WebConstants.LOGIN_RESULT.USER_LOCKED
|
|
||||||
);
|
|
||||||
}else if(userInfo.getStatus()!=ConstsStatus.ACTIVE) {
|
|
||||||
authenticationRealm.insertLoginHistory(
|
|
||||||
userInfo,
|
|
||||||
loginCredential.getAuthType(),
|
|
||||||
loginCredential.getProvider(),
|
|
||||||
loginCredential.getCode(),
|
|
||||||
WebConstants.LOGIN_RESULT.USER_INACTIVE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean statusValid(LoginCredential loginCredential , UserInfo userInfo) {
|
||||||
|
if(userInfo.getIsLocked()==ConstsStatus.LOCK) {
|
||||||
|
authenticationRealm.insertLoginHistory(
|
||||||
|
userInfo,
|
||||||
|
loginCredential.getAuthType(),
|
||||||
|
loginCredential.getProvider(),
|
||||||
|
loginCredential.getCode(),
|
||||||
|
WebConstants.LOGIN_RESULT.USER_LOCKED
|
||||||
|
);
|
||||||
|
}else if(userInfo.getStatus()!=ConstsStatus.ACTIVE) {
|
||||||
|
authenticationRealm.insertLoginHistory(
|
||||||
|
userInfo,
|
||||||
|
loginCredential.getAuthType(),
|
||||||
|
loginCredential.getProvider(),
|
||||||
|
loginCredential.getCode(),
|
||||||
|
WebConstants.LOGIN_RESULT.USER_INACTIVE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,6 +84,8 @@ public class MfaAuthenticationProvider extends AbstractAuthenticationProvider {
|
|||||||
|
|
||||||
userInfo = loadUserInfo(loginCredential.getUsername(),loginCredential.getPassword());
|
userInfo = loadUserInfo(loginCredential.getUsername(),loginCredential.getPassword());
|
||||||
|
|
||||||
|
isUserExist(loginCredential , userInfo);
|
||||||
|
|
||||||
statusValid(loginCredential , userInfo);
|
statusValid(loginCredential , userInfo);
|
||||||
//mfa
|
//mfa
|
||||||
mfacaptchaValid(loginCredential.getOtpCaptcha(),userInfo);
|
mfacaptchaValid(loginCredential.getOtpCaptcha(),userInfo);
|
||||||
|
|||||||
@ -90,10 +90,9 @@ public class MobileAuthenticationProvider extends AbstractAuthenticationProvider
|
|||||||
|
|
||||||
UserInfo userInfo = loadUserInfo(loginCredential.getUsername(),loginCredential.getPassword());
|
UserInfo userInfo = loadUserInfo(loginCredential.getUsername(),loginCredential.getPassword());
|
||||||
|
|
||||||
statusValid(loginCredential , userInfo);
|
isUserExist(loginCredential , userInfo);
|
||||||
|
|
||||||
//Validate PasswordPolicy 取消密码策略验证
|
statusValid(loginCredential , userInfo);
|
||||||
//authenticationRealm.getPasswordPolicyValidator().passwordPolicyValid(userInfo);
|
|
||||||
|
|
||||||
mobileCaptchaValid(loginCredential.getPassword(),userInfo);
|
mobileCaptchaValid(loginCredential.getPassword(),userInfo);
|
||||||
|
|
||||||
|
|||||||
@ -91,11 +91,13 @@ public class NormalAuthenticationProvider extends AbstractAuthenticationProvider
|
|||||||
|
|
||||||
UserInfo userInfo = loadUserInfo(loginCredential.getUsername(),loginCredential.getPassword());
|
UserInfo userInfo = loadUserInfo(loginCredential.getUsername(),loginCredential.getPassword());
|
||||||
|
|
||||||
statusValid(loginCredential , userInfo);
|
isUserExist(loginCredential , userInfo);
|
||||||
|
|
||||||
//Validate PasswordPolicy
|
//Validate PasswordPolicy
|
||||||
authenticationRealm.getPasswordPolicyValidator().passwordPolicyValid(userInfo);
|
authenticationRealm.getPasswordPolicyValidator().passwordPolicyValid(userInfo);
|
||||||
|
|
||||||
|
statusValid(loginCredential , userInfo);
|
||||||
|
|
||||||
//Match password
|
//Match password
|
||||||
authenticationRealm.passwordMatches(userInfo, loginCredential.getPassword());
|
authenticationRealm.passwordMatches(userInfo, loginCredential.getPassword());
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user