邮箱正则校验
parent
cccf0a2ba2
commit
748266f8db
|
@ -18,6 +18,8 @@ import com.muyu.system.remote.RemoteUserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
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.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, "邮箱错误,请检查");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "邮箱错误,请检查");
|
||||||
throw new ServiceException("邮箱错误,请检查:" + username);
|
throw new ServiceException("邮箱错误,请检查:" + username);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue