diff --git a/nflg-mobilebroken-auth/src/main/java/com/nflg/mobilebroken/auth/controller/AppController.java b/nflg-mobilebroken-auth/src/main/java/com/nflg/mobilebroken/auth/controller/AppController.java index da5972ad..18489dca 100644 --- a/nflg-mobilebroken-auth/src/main/java/com/nflg/mobilebroken/auth/controller/AppController.java +++ b/nflg-mobilebroken-auth/src/main/java/com/nflg/mobilebroken/auth/controller/AppController.java @@ -14,6 +14,8 @@ import com.nflg.mobilebroken.common.util.*; import com.nflg.mobilebroken.repository.entity.AdminUser; import com.nflg.mobilebroken.repository.entity.AppUser; import com.nflg.mobilebroken.repository.service.*; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -48,6 +50,7 @@ public class AppController extends ControllerBase { @Resource private IAdminUserRoleMapService adminUserRoleMapService; + private static final PasswordEncoder PASSWORDENCODER = new BCryptPasswordEncoder(); /** * 用户端登录 @@ -59,6 +62,8 @@ public class AppController extends ControllerBase { public ApiResult login(String userName, String password) { AppUser user = appUserService.getUser(userName, password); if (Objects.nonNull(user)) { + VUtils.trueThrowBusinessError(!PASSWORDENCODER.matches(password, user.getPassword())) + .throwMessage(dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_INCORRECTUSERNAMEORPASSWORD, MultilingualUtil.getLanguage())); VUtils.trueThrow(Objects.equals(user.getState(), UserState.Disabled.getState())) .throwMessage(STATE.PassportErr, dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_ACCOUNT_DISABLED, user.getLanguageCode())); VUtils.trueThrow(Objects.equals(user.getState(), UserState.ToBeActivated.getState())) diff --git a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserServiceImpl.java b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserServiceImpl.java index 8465ecdd..f67fe958 100644 --- a/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserServiceImpl.java +++ b/nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/AppUserServiceImpl.java @@ -11,7 +11,10 @@ import com.nflg.mobilebroken.common.exception.NflgException; import com.nflg.mobilebroken.common.pojo.PageData; import com.nflg.mobilebroken.common.pojo.request.*; import com.nflg.mobilebroken.common.pojo.vo.*; -import com.nflg.mobilebroken.common.util.*; +import com.nflg.mobilebroken.common.util.AdminUserUtil; +import com.nflg.mobilebroken.common.util.AppUserUtil; +import com.nflg.mobilebroken.common.util.PageUtil; +import com.nflg.mobilebroken.common.util.VUtils; import com.nflg.mobilebroken.repository.entity.*; import com.nflg.mobilebroken.repository.mapper.AppUserMapper; import com.nflg.mobilebroken.repository.service.*; @@ -75,8 +78,6 @@ public class AppUserServiceImpl extends ServiceImpl impl .eq(AppUser::getIsDel, false) .eq(AppUser::getLoginName, userName) .one(); - VUtils.trueThrowBusinessError(Objects.isNull(user) || !PASSWORDENCODER.matches(password, user.getPassword())) - .throwMessage(dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_SYSTEMERROR, Constant.DICTIONARY_ITEM_INCORRECTUSERNAMEORPASSWORD, MultilingualUtil.getLanguage())); return user; }