From bdfb249691a4b872c973ae976359d9a01b171ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Wed, 29 Sep 2021 21:32:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=94=B9=E5=96=84=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/_posts/shiro-spring.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_posts/shiro-spring.md b/source/_posts/shiro-spring.md index 0865405..8f85b49 100644 --- a/source/_posts/shiro-spring.md +++ b/source/_posts/shiro-spring.md @@ -343,7 +343,7 @@ public class UsernameRealm extends AuthoringRealm { var token = (UsernamePasswordToken) authenticationToken; return memberRepository.findMemberByUsername((String) token.getPrincipal()) .map(member -> new SimpleAuthenticationInfo(member, member.getPassword(), member.getFulLName())) - .orElse(null); + .orElseThrow(() -> new AuthenticationException("用户不存在。")); } } ``` @@ -407,7 +407,7 @@ public class TokenRealm extends AuthorizingRealm { return storeRepository.findTokenById(token.getToken()) .filter(t -> t.getExpires().isAfter(LocalDateTime.now())) .map(t -> new SimpleAuthenticationInfo(t.getMember(), t.getToken(), t.getMember().getFulLName())) - .orElse(null); + .orElseThrow(() -> new AuthenticationException("用户令牌不存在。")); } } ```