From 3157a48e731a8a3bde9ce83faef636fe0887ca81 Mon Sep 17 00:00:00 2001 From: terrfly Date: Wed, 16 Jun 2021 14:16:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AF=86=E7=A0=81=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=9C=89=E8=AF=AF=E6=8F=90=E7=A4=BA=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/jeequan/jeepay/mgr/service/AuthService.java | 4 ++++ .../main/java/com/jeequan/jeepay/mch/service/AuthService.java | 3 +++ 2 files changed, 7 insertions(+) diff --git a/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/service/AuthService.java b/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/service/AuthService.java index 20d73d8..34c4225 100644 --- a/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/service/AuthService.java +++ b/jeepay-manager/src/main/java/com/jeequan/jeepay/mgr/service/AuthService.java @@ -33,6 +33,7 @@ import com.jeequan.jeepay.service.mapper.SysEntitlementMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; @@ -81,10 +82,13 @@ public class AuthService { authentication = authenticationManager.authenticate(upToken); } catch (JeepayAuthenticationException jex) { throw jex.getBizException() == null ? new BizException(jex.getMessage()) : jex.getBizException(); + } catch (BadCredentialsException e) { + throw new BizException("用户名/密码错误!"); } catch (AuthenticationException e) { log.error("AuthenticationException:", e); throw new BizException("认证服务出现异常, 请重试或联系系统管理员!"); } + JeeUserDetails jeeUserDetails = (JeeUserDetails) authentication.getPrincipal(); //验证通过后 再查询用户角色和权限信息集合 diff --git a/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/service/AuthService.java b/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/service/AuthService.java index b12dc68..2c8caf1 100644 --- a/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/service/AuthService.java +++ b/jeepay-merchant/src/main/java/com/jeequan/jeepay/mch/service/AuthService.java @@ -35,6 +35,7 @@ import com.jeequan.jeepay.service.mapper.SysEntitlementMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; @@ -83,6 +84,8 @@ public class AuthService { authentication = authenticationManager.authenticate(upToken); } catch (JeepayAuthenticationException jex) { throw jex.getBizException() == null ? new BizException(jex.getMessage()) : jex.getBizException(); + } catch (BadCredentialsException e) { + throw new BizException("用户名/密码错误!"); } catch (AuthenticationException e) { log.error("AuthenticationException:", e); throw new BizException("认证服务出现异常, 请重试或联系系统管理员!"); -- GitLab