| | |
| | | package com.ruoyi.auth.service; |
| | | |
| | | import com.ruoyi.system.api.RemoteMemberService; |
| | | import com.ruoyi.system.api.model.AppMiniLoginDto; |
| | | import com.ruoyi.system.api.model.AppMiniLoginVo; |
| | | import com.ruoyi.system.api.model.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.RemoteUserService; |
| | | import com.ruoyi.system.api.domain.poji.sys.SysUser; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | |
| | | /** |
| | | * 登录校验方法 |
| | | * |
| | | * |
| | | * @author jqs |
| | | */ |
| | | @Component |
| | |
| | | { |
| | | throw new ServiceException(userResult.getMsg()); |
| | | } |
| | | |
| | | |
| | | LoginUser userInfo = userResult.getData(); |
| | | SysUser user = userResult.getData().getSysUser(); |
| | | if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) |
| | |
| | | return userInfo; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 企业微信H5登录 |
| | | */ |
| | | public QwH5LoginVo qwH5Login(QwUserDetailDto qwUserDetail) |
| | | { |
| | | // 查询用户信息 |
| | | R<QwH5LoginVo> userResult = remoteUserService.qwH5Login(qwUserDetail); |
| | | if (R.FAIL == userResult.getCode()) |
| | | { |
| | | throw new ServiceException(userResult.getMsg()); |
| | | } |
| | | QwH5LoginVo userInfo = userResult.getData(); |
| | | SysUser user = userInfo.getSysUser(); |
| | | 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("对不起,您的账号:" + username + " 已被删除"); |
| | | } |
| | | if (UserStatus.DISABLE.getCode().equals(user.getStatus())) |
| | | { |
| | | recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); |
| | | throw new ServiceException("对不起,您的账号:" + username + " 已停用"); |
| | | } |
| | | recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); |
| | | return userInfo; |
| | | } |
| | | |
| | | public void logout(String loginName) |
| | | { |
| | | recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功"); |
| | |
| | | SysUser sysUser = new SysUser(); |
| | | sysUser.setUserName(username); |
| | | sysUser.setNickName(username); |
| | | sysUser.setUserType("00"); |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(password)); |
| | | R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER); |
| | | |