1、bug#565 登录校验优化;2、发送短信只在修改手机时校验用户登录;

This commit is contained in:
gaoqr
2024-10-15 17:44:57 +08:00
parent fb7f1575e2
commit 1c3dcab0db
4 changed files with 10 additions and 6 deletions
@@ -105,8 +105,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
// 校验机构有效性
organService.validOrgan(user.getOrganId());
// 校验密码
String userPassword = user.getPassword();
if (StringUtils.isNotEmpty(userPassword) && !userService.isPasswordMatch(password, userPassword)) {
if (!userService.isPasswordMatch(password, user.getPassword())) {
createLoginLog(user.getId(), username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS);
throw ServiceExceptionUtil.exception(ErrorCodeConstants.AUTH_LOGIN_BAD_CREDENTIALS);
}
@@ -60,9 +60,6 @@ public class SmsCodeServiceImpl implements SmsCodeService {
public void sendSmsCode(SmsCodeSendReqDTO reqDTO) {
AdminUserDO user = userService.getUserByUsernameAndOrganId(reqDTO.getMobile(), null);
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
}
// 更新手机号场景检查
if (ObjectUtil.equal(SmsSceneEnum.USER_UPDATE_MOBILE.getScene(), reqDTO.getScene())) {
userUpdateMobileValid(user, loginUser);
@@ -89,6 +86,9 @@ public class SmsCodeServiceImpl implements SmsCodeService {
* @param loginUser
*/
private void userUpdateMobileValid(AdminUserDO user, LoginUser loginUser) {
if (ObjectUtil.isNull(loginUser)) {
throw new ServiceException(GlobalErrorCodeConstants.UNAUTHORIZED);
}
if (ObjectUtil.isNotNull(user)) {
if (ObjectUtil.equal(user.getId(), loginUser.getId())) {
// 手机号没有改变无需验证码