| | |
| | | import com.ruoyi.system.api.domain.AppMiniLoginVO; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.domain.dto.AppMiniLoginDTO; |
| | | import com.ruoyi.system.api.domain.dto.AppMiniRegisterDTO; |
| | | import com.ruoyi.system.api.feignClient.AuctionClient; |
| | | import com.ruoyi.system.api.feignClient.MemberClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import javax.annotation.Resource; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * 登录校验方法 |
| | |
| | | |
| | | @Resource |
| | | private MemberClient MemberClient; |
| | | |
| | | @Resource |
| | | private AuctionClient uctionClient; |
| | | |
| | | /** |
| | | * 登录 |
| | |
| | | return userInfo; |
| | | } |
| | | |
| | | public AppMiniLoginVO miniRegister(AppMiniRegisterDTO appUserRegisterDto) |
| | | { |
| | | // 查询用户信息 |
| | | R<AppMiniLoginVO> userResult = MemberClient.miniRegister(appUserRegisterDto); |
| | | if (R.FAIL == userResult.getCode()) |
| | | { |
| | | throw new ServiceException(userResult.getMsg()); |
| | | } |
| | | AppMiniLoginVO appMiniRegisterVo = userResult.getData(); |
| | | SysUser user=appMiniRegisterVo.getSysUser(); |
| | | if(appMiniRegisterVo.getSysUser()!=null){ |
| | | String username = user.getUserName(); |
| | | // IP黑名单校验 |
| | | String blackStr = Convert.toStr(redisService.getCacheObject(CacheConstants.SYS_LOGIN_BLACKIPLIST)); |
| | | if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) |
| | | { |
| | | recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "很遗憾,访问IP已被列入系统黑名单"); |
| | | throw new ServiceException("很遗憾,访问IP已被列入系统黑名单"); |
| | | } |
| | | if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) |
| | | { |
| | | recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); |
| | | throw new ServiceException("对不起,您的账号: 已被删除"); |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(user.getStatus())) |
| | | { |
| | | recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); |
| | | throw new ServiceException("对不起,您的账号: 已停用"); |
| | | } |
| | | recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); |
| | | } |
| | | return appMiniRegisterVo; |
| | | } |
| | | |
| | | public AppMiniLoginVO actionMiniLogin(AppMiniLoginDTO appMiniLoginDto) |
| | | { |
| | | // 查询用户信息 |
| | | R<AppMiniLoginVO> userResult = MemberClient.actionMiniLogin(appMiniLoginDto); |
| | | R<AppMiniLoginVO> userResult = uctionClient.actionMiniLogin(appMiniLoginDto); |
| | | if (R.FAIL == userResult.getCode()) |
| | | { |
| | | throw new ServiceException(userResult.getMsg()); |
| | |
| | | if (!verificationCodeCache.equals(verificationCode)) { |
| | | throw new ServiceException("验证码错误,请重新输入!"); |
| | | } |
| | | // 校验密码,6位数数字 |
| | | if (!password.matches("^\\d{6}$")) { |
| | | throw new ServiceException("密码必须为6位数字!"); |
| | | } |
| | | R<LoginUser> userInfo = remoteUserService.getUserInfo(username, SecurityConstants.INNER); |
| | | if (R.FAIL == userInfo.getCode()) { |
| | | throw new ServiceException(userInfo.getMsg()); |
| | | } |
| | | remoteUserService.changePassword(username, SecurityUtils.encryptPassword(password), |
| | | SecurityConstants.INNER); |
| | | redisService.deleteObject( |
| | | CacheConstants.CHANGE_PASSWORD_CAPTCHA_CODE_KEY + username); |
| | | } |
| | | } |