| | |
| | | // 查询用户信息 |
| | | R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); |
| | | |
| | | if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) |
| | | { |
| | | recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在"); |
| | | throw new ServiceException("登录用户:" + username + " 不存在"); |
| | | } |
| | | |
| | | if (R.FAIL == userResult.getCode()) |
| | | { |
| | | throw new ServiceException(userResult.getMsg()); |
| | | } |
| | | |
| | | |
| | | LoginUser userInfo = userResult.getData(); |
| | | SysUser user = userResult.getData().getSysUser(); |
| | | if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) |
| | |
| | | remoteUserService.recordUserLogin(sysUser, SecurityConstants.INNER); |
| | | } |
| | | |
| | | /** |
| | | * 退出 |
| | | */ |
| | | public void logout(String loginName) |
| | | { |
| | | recordLogService.recordLogininfor(loginName, Constants.LOGOUT, "退出成功"); |
| | | } |
| | | |
| | | /** |
| | | * 解锁 |
| | | */ |
| | | public void unlock(String password) |
| | | { |
| | | String username = SecurityUtils.getUsername(); |
| | | // 或密码为空 错误 |
| | | if (StringUtils.isEmpty(password)) |
| | | { |
| | | throw new ServiceException("密码不能为空"); |
| | | } |
| | | // 查询用户信息 |
| | | R<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); |
| | | |
| | | if (R.FAIL == userResult.getCode()) |
| | | { |
| | | throw new ServiceException(userResult.getMsg()); |
| | | } |
| | | |
| | | SysUser user = userResult.getData().getSysUser(); |
| | | if (!SecurityUtils.matchesPassword(password, user.getPassword())) |
| | | { |
| | | throw new ServiceException("密码错误,请重新输入"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | SysUser sysUser = new SysUser(); |
| | | sysUser.setUserName(username); |
| | | sysUser.setNickName(username); |
| | | sysUser.setPwdUpdateDate(DateUtils.getNowDate()); |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(password)); |
| | | R<?> registerResult = remoteUserService.registerUserInfo(sysUser, SecurityConstants.INNER); |
| | | |