From 4ec6d51aca7f106a7eaa63a4f22e4fa0680ba5d1 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 17 Sep 2020 12:08:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java | 2 +- .../src/main/java/com/ruoyi/auth/service/SysLoginService.java | 6 ++++++ .../com/ruoyi/common/security/handler/GlobalExceptionHandler.java | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java index 1d4a582..6254ac7 100644 --- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java +++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteUserFallbackFactory.java @@ -27,7 +27,7 @@ public class RemoteUserFallbackFactory implements FallbackFactory getUserInfo(String username) { - return null; + return R.fail("获取用户失败:" + throwable.getMessage()); } }; } diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java index 611bee4..6c7ad50 100644 --- a/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java +++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/service/SysLoginService.java @@ -55,6 +55,12 @@ public class SysLoginService } // 查询用户信息 R userResult = remoteUserService.getUserInfo(username); + + if (R.FAIL == userResult.getCode()) + { + throw new BaseException(userResult.getMsg()); + } + if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) { remoteLogService.saveLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在"); diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java index 7e569d6..1a3070c 100644 --- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java +++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java @@ -29,7 +29,7 @@ public class GlobalExceptionHandler @ExceptionHandler(BaseException.class) public AjaxResult baseException(BaseException e) { - return AjaxResult.error(e.getMessage()); + return AjaxResult.error(e.getDefaultMessage()); } /**