| | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.config.jwt.JwtTokenUtil; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.utils.DateUtil; |
| | | import com.doumee.dao.system.dto.LoginCabinetDTO; |
| | | import com.doumee.dao.system.dto.LoginH5DTO; |
| | | import com.doumee.service.business.third.TmsService; |
| | | import com.doumee.service.business.third.model.LoginUserInfo; |
| | |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public LoginUserInfo loginByPasswordForCabinet(LoginCabinetDTO dto, ServerHttpRequest request) { |
| | | SystemLoginLog loginLog = getInitLoginlog(dto.getUsername(),request); |
| | | try { |
| | | LoginUserInfo user = dealLoginByPwdNewBiz(dto.getUsername(),dto.getPassword(),null,null,null,request); |
| | | systemLoginLogService.create(loginLog); |
| | | return user; |
| | | }catch (BusinessException e){ |
| | | loginLog.setSuccess(Boolean.FALSE); |
| | | systemLoginLogService.create(loginLog); |
| | | throw e; |
| | | |
| | | }catch (Exception e){ |
| | | loginLog.setSuccess(Boolean.FALSE); |
| | | systemLoginLogService.create(loginLog); |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public LoginUserInfo loginH5 (LoginH5DTO dto, ServerHttpRequest request) { |
| | | SystemLoginLog loginLog = getInitLoginlog(dto.getUsername(),request); |
| | |
| | | return userInfo; |
| | | } |
| | | |
| | | |
| | | public void checkPassword(SystemUser user,String pwd){ |
| | | String pppp = Utils.Secure.encryptPassword(new String(pwd), user.getSalt()); |
| | | // 比较密码 |
| | | if( !StringUtils.equals(pppp, user.getPassword())){ |
| | | //是否开启密码错误禁止登录:0=否;1=是; |
| | | SystemDictData prohibitLoginData = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROHIBIT_LOGIN_OPEN); |
| | | if(Objects.nonNull(prohibitLoginData)&&"1".equals(prohibitLoginData.getCode())){ |
| | | SystemDictData prohibitErrTimesData = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ERR_TIMES); |
| | | if(Objects.nonNull(prohibitErrTimesData)){ |
| | | |
| | | } |
| | | throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT); |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.ACCOUNT_INCORRECT); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | public void updErrTimes(SystemUser systemUser){ |
| | | //最大错误次数 进行登录限制 |
| | | SystemDictData prohibitErrTimesData = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.ERR_TIMES); |
| | | //是否开启密码错误禁止登录:0=否;1=是; |
| | | SystemDictData prohibitLoginData = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROHIBIT_LOGIN_OPEN); |
| | | //密码错误禁止登录限制时间(分钟) |
| | | SystemDictData prohibitTimeData = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROHIBIT_TIME); |
| | | if(Objects.isNull(prohibitTimeData)||Objects.isNull(prohibitLoginData)||Objects.isNull(prohibitTimeData)){ |
| | | return; |
| | | } |
| | | systemUserMapper.update(null,new UpdateWrapper<SystemUser>().lambda() |
| | | .setSql( " PROHIBIT_STATUS = CASE WHEN "+prohibitLoginData+" = 1 and ( IFNULL(ERR_TIMES,0) + 1 ) > "+prohibitErrTimesData.getCode()+" then 1 else 0 end ") |
| | | .setSql(" PROHIBIT_TIME = CASE WHEN PROHIBIT_STATUS = 1 then DATE_ADD(NOW(), INTERVAL "+prohibitTimeData.getCode()+" MINUTE) else null end , ") |
| | | .setSql(" ERR_TIMES = (ifnull(ERR_TIMES,0) + 1) ") |
| | | .eq(SystemUser::getId,systemUser.getId()) |
| | | ); |
| | | } |
| | | |
| | | public void prohibitLogin(SystemUser systemUser){ |
| | | if(Constants.equalsInteger(systemUser.getProhibitStatus(),Constants.ZERO)){ |
| | | Long betweenMin = DateUtil.getBetweenMin(systemUser.getProhibitTime(),new Date()); |
| | | if(betweenMin <= 0L){ |
| | | betweenMin = 0L; |
| | | } |
| | | throw new BusinessException( ResponseStatus.NOT_ALLOWED.getCode(),"密码错误次数过多,请后"+ betweenMin +"分钟后重试"); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public LoginUserInfo loginByPasswordForPda(LoginDTO dto, ServerHttpRequest request) { |
| | | SystemLoginLog loginLog =getInitLoginlog(dto.getUsername(),request); |