用户/邮箱登录

dev
Yunfei Du 2024-04-12 14:20:01 +08:00
parent 94d0c44100
commit b7f8779e21
3 changed files with 9 additions and 3 deletions

View File

@ -67,7 +67,10 @@ public class SysLoginService {
// 查询用户信息
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
if ((StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))&& username.contains ( "@" )) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录邮箱不存在");
throw new ServiceException("登录邮箱:" + username + " 不存在");
}else if ((StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData()))){
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
throw new ServiceException("登录用户:" + username + " 不存在");
}

View File

@ -100,7 +100,10 @@ public class SysUserController extends BaseController {
@GetMapping("/info/{username}")
public Result<LoginUser> info (@PathVariable("username") String username) {
SysUser sysUser = userService.selectUserByUserName(username);
if (StringUtils.isNull(sysUser)) {
if (StringUtils.isNull(sysUser) && username.contains ( "@" )) {
return Result.error("邮箱或密码错误");
}
else if (StringUtils.isNull(sysUser)){
return Result.error("用户名或密码错误");
}
// 角色集合

View File

@ -152,7 +152,7 @@
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_name = #{userName} and u.del_flag = '0'
where u.user_name or u.email =#{userName} and u.del_flag = '0'
</select>
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">