| | |
| | | } |
| | | |
| | | public ServiceModel searchSnIdByUId(Integer uId) { |
| | | ServiceModel model = new ServiceModel(); |
| | | /*ServiceModel model = new ServiceModel(); |
| | | User_inf userInf = ((User_infImpl)dao).searchSnIdByUId(uId); |
| | | model.setCode(1); |
| | | model.setData(userInf); |
| | | return model;*/ |
| | | |
| | | List list = ((User_infImpl)dao).searchSnIdByUId(uId); |
| | | if (list == null || list.size() < 1) { |
| | | model.setMsg("对应的用户不存在"); |
| | | } else { |
| | | User_inf u = (User_inf) list.get(0); |
| | | /** |
| | | * 先判断账户是否为激活账号 |
| | | * @see com.fgkj.constant.UserConstant |
| | | */ |
| | | if(u.getStatus()!=1){ |
| | | switch (u.getStatus()){ |
| | | case 0: model.setMsg("当前账号的状态异常,无法登录. 异常信息为: "+UserConstant.ACCOUNT_STATUS_CANCEL.getLabel());break; |
| | | case 2: model.setMsg("当前账号的状态异常,无法登录. 异常信息为: "+UserConstant.ACCOUNT_STATUS_HIBERNATE.getLabel());break; |
| | | case 3: model.setMsg("当前账号的状态异常,无法登录. 异常信息为: "+UserConstant.ACCOUNT_STATUS_LOCK.getLabel());break; |
| | | case 4: model.setMsg("当前账号的状态异常,无法登录. 异常信息为: "+UserConstant.ACCOUNT_STATUS_LOCK_FAIL.getLabel());break; |
| | | default:model.setMsg("当前账号的状态异常,无法登录. 异常信息为: 无"); |
| | | } |
| | | return model; |
| | | } |
| | | //判断是否为国网系统,校验密码是否3个月修改过一次 |
| | | if("1".equals(PropertiesUtil.props.get("system.type"))){ |
| | | |
| | | //登录之前,首先校验允许时间和登录ip |
| | | boolean ipPass = true; |
| | | |
| | | String firstTime = u.getVisitTime().split("~")[0]; |
| | | String lastTime = u.getVisitTime().split("~")[1]; |
| | | |
| | | List<String> ipRules = new LinkedList<>(); |
| | | String ipRuleStr = u.getVisitIp(); |
| | | ipRules = Arrays.asList(ipRuleStr.split(",")); |
| | | |
| | | Calendar instance = Calendar.getInstance(); |
| | | String hourOfDay = String.format("%1$02d",instance.get(Calendar.HOUR_OF_DAY)); |
| | | int minute = instance.get(Calendar.MINUTE); |
| | | int second = instance.get(Calendar.SECOND); |
| | | String nowTime = hourOfDay+":"+minute+":"+second; |
| | | //登录时间校验 |
| | | if(nowTime.compareTo(firstTime)>=0 && nowTime.compareTo(lastTime)<=0){ |
| | | //登录ip校验 |
| | | String clientIp = ActionUtil.getRequest().getRemoteAddr(); |
| | | if(!ipRules.contains("*")){ |
| | | for(String ipRule:ipRules){ |
| | | ipPass = true; |
| | | //ip规则格式为 * 或者 xxx.xxx.x.x |
| | | String[] ipArr = clientIp.split("\\."); |
| | | String[] ipRuleArr = ipRule.split("\\."); |
| | | for (int i = 0; i < ipRuleArr.length; i++) { |
| | | if(!ipRuleArr[i].equals("*") && !ipRuleArr[i].equals(ipArr[i])){ |
| | | ipPass = false; |
| | | break; |
| | | } |
| | | } |
| | | if(ipPass){ |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if(!ipPass){ |
| | | return new ServiceModel().setMsgII(0,"您的IP禁止访问,请知晓"); |
| | | } |
| | | }else{ |
| | | return new ServiceModel().setMsgII(0,"登录时间不在允许的时间范围内"); |
| | | } |
| | | |
| | | /*Date passwordUpdateTime = u.getPasswordUpdateTime(); |
| | | Calendar now = Calendar.getInstance(); |
| | | now.add(Calendar.MONTH,-3); |
| | | if(passwordUpdateTime==null){ //密码修改时间为空,尚未修改初始口令 |
| | | model.setCode(3); |
| | | model.setMsg("首次登录,请先修改初始化口令"); |
| | | return model; |
| | | } |
| | | else if(passwordUpdateTime.compareTo(now.getTime()) < 0){ |
| | | model.setCode(2); |
| | | model.setMsg("超过3个月没有修改口令,请修改口令后重新登录"); |
| | | return model; |
| | | }*/ |
| | | } |
| | | |
| | | { |
| | | //校验通过,登录成功 |
| | | model.setCode(1); |
| | | //model.setMsg("index.jsp"); |
| | | model.setMsg("index-outline.jsp"); |
| | | //查询用户对应的权限组id并返回给前端 |
| | | int permitGroupId = new User_permitgroup_dataImpl().getPermitGroupId(uId); |
| | | model.setSum(permitGroupId); |
| | | // 将登陆成功的用户存入session |
| | | HttpSession session = ActionUtil.getSession(); |
| | | // System.out.println(session); |
| | | session.setAttribute("user", u); |
| | | |
| | | //设置session不活动时间为30分 |
| | | session.setMaxInactiveInterval(60*30); |
| | | session.setAttribute("ip",ActionUtil.getRequest().getRemoteAddr()); |
| | | User_permitgroupService upgs=new User_permitgroupService(); |
| | | ServiceModel model1=upgs.serchItem(u); |
| | | //System.out.println(model.getData()); |
| | | if(model1.getCode()==1){ |
| | | session.setAttribute("permits", ActionUtil.tojson(model1.getData())); |
| | | }else{ |
| | | model.setCode(0); |
| | | model.setMsg("还未分配权限"); |
| | | } |
| | | //将新登录的用户存入application |
| | | setApplication(u); |
| | | //集群专用 |
| | | //new User_infService_Cluster().setApplication(u); |
| | | } |
| | | } |
| | | return model; |
| | | } |
| | | |