From 748266f8dbb1e1e95bba55f53debce53a7e102d4 Mon Sep 17 00:00:00 2001 From: liyongjie <1318551549@qq.com> Date: Fri, 19 Apr 2024 22:02:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E7=AE=B1=E6=AD=A3=E5=88=99=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/muyu/auth/service/SysLoginService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/muyu-auth/src/main/java/com/muyu/auth/service/SysLoginService.java b/muyu-auth/src/main/java/com/muyu/auth/service/SysLoginService.java index 9df3ab9..7eecab1 100644 --- a/muyu-auth/src/main/java/com/muyu/auth/service/SysLoginService.java +++ b/muyu-auth/src/main/java/com/muyu/auth/service/SysLoginService.java @@ -18,6 +18,8 @@ import com.muyu.system.remote.RemoteUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.regex.*; + /** * 登录校验方法 @@ -76,7 +78,10 @@ public class SysLoginService if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) { - if(StringUtils.contains(username, "@")){ + String emailRegex = "^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$"; + Pattern pattern = Pattern.compile(emailRegex); + Matcher matcher = pattern.matcher(username); + if(!matcher.matches()){ recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "邮箱错误,请检查"); throw new ServiceException("邮箱错误,请检查:" + username); }