| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.whyc.constant.UserConstant; |
| | | import com.whyc.constant.UserLogTypeEnum; |
| | | import com.whyc.constant.YamlProperties; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.UserClient; |
| | | import com.whyc.mapper.PageParamMapper; |
| | | import com.whyc.mapper.UserMapper; |
| | | import com.whyc.pojo.db_app_sys.PageParam; |
| | | import com.whyc.pojo.db_user.Permitgroup; |
| | | import com.whyc.pojo.db_user.PermitgroupUsr; |
| | | import com.whyc.pojo.db_user.User; |
| | | import com.whyc.util.*; |
| | |
| | | import javax.servlet.ServletContext; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | |
| | | |
| | | @Resource |
| | | private PermitGroupUserService permitGroupUserService; |
| | | |
| | | @Resource |
| | | private PermitGroupService permitGroupService; |
| | | |
| | | @Autowired |
| | | private BaojigroupService bjService; |
| | |
| | | } |
| | | //验证正确,清除验证码 |
| | | ActionUtil.getSession().removeAttribute("fontDynamicCode"); |
| | | /*String password = ""; |
| | | try { |
| | | password = URLDecoder.decode(pwd, "utf-8"); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | }*/ |
| | | String[] dataArr = RSAUtil.decryptFront(pwd, RSAUtil.fontSeparator); |
| | | |
| | | String[] dataArr = RSAUtil.decryptFrontP(pwd, RSAUtil.fontSeparator); |
| | | //验签md5 |
| | | if (!dataArr[1].equals(ActionUtil.EncryptionMD5(org.apache.commons.lang3.StringUtils.trim(dataArr[0])).toString())) { |
| | | return response.set(1, false, "密码验签失败"); |
| | |
| | | Enumeration<String> attributeNames = servletContext.getAttributeNames(); |
| | | |
| | | QueryWrapper<User> queryWrapper = Wrappers.query(); |
| | | queryWrapper.select("id", "status", "visit_ip", "visit_time", "password_update_time", "last_login_time").eq("name", userName); |
| | | queryWrapper.select("id","name","role","status", "visit_ip", "visit_time", "password_update_time", "last_login_time").eq("name", userName); |
| | | User userInf = userMapper.selectOne(queryWrapper); |
| | | //每个登录的用户都有一个全局变量,里面存着对应的SessionId; |
| | | //同一个账号,后面登录的,会挤掉之前登录的SessionId,这个todo,做限制账号同时登陆人数为1 |
| | |
| | | } else { |
| | | servletContext.setAttribute(userName + "_login_fail_times_" + System.currentTimeMillis(), 0); |
| | | } |
| | | // CommonUtil.record(0, UserOperation.TYPE_LOGIN_FAIL.getType(), UserOperation.TYPE_LOGIN_FAIL.getTypeName(), UserOperation.TYPE_LOGIN_FAIL.getTypeNameEn()); |
| | | CommonUtil.record( UserLogTypeEnum.CATEGORY_SYSTEM.getType(), UserLogTypeEnum.LOGIN_FAIL.getType(),UserLogTypeEnum.LOGIN_FAIL.getName(), UserLogTypeEnum.LOGIN_FAIL.getName()); |
| | | return response.set(1, false, "账号或密码错误"); |
| | | }else if(e instanceof AuthenticationException){ |
| | | return response.set(1, false, "密码解析失败"); |
| | |
| | | pageParam2Service.updateVisitCount();*/ |
| | | //Session存储当前用户及权限组列表 |
| | | request.getSession().setAttribute("user", subject.getPrincipal()); |
| | | request.getSession().setMaxInactiveInterval(60*60*24); |
| | | request.getSession().setMaxInactiveInterval(60*30); |
| | | request.getSession().setAttribute("permits", ActionUtil.getGson().toJson(permitGroupUserService.getItemList(userInf.getId()))); |
| | | //清除账号登录失败记录 |
| | | while (attributeNames.hasMoreElements()) { |
| | |
| | | //回写登录时间到数据库 |
| | | userService.updateLoginTime(userInf.getId()); |
| | | //查询用户对应的权限组id并返回给前端 |
| | | LinkedList<Object> dataList = new LinkedList<>(); |
| | | dataList.add(subject.getPrincipal()); |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("user",userInf); |
| | | PermitgroupUsr permitGroup = permitGroupUserService.getPermitGroup(userInf.getId()); |
| | | if(permitGroup == null){ |
| | | return response.set(1, false, "当前用户没有对应的权限组,登录失败"); |
| | | }else { |
| | | int permitGroupId = permitGroup.getPermitGroupId(); |
| | | dataList.add(permitGroupId); |
| | | //int permitGroupId = permitGroup.getPermitGroupId(); |
| | | //查询权限组信息 |
| | | List<Permitgroup> permitgroupList=permitGroupUserService.getPermitByUser(userInf.getId()); |
| | | map.put("permit",permitgroupList); |
| | | } |
| | | //查询用户对应的班组标识 |
| | | dataList.add(bjService.getGroupFlag(userInf.getId().intValue())); |
| | | // CommonUtil.record(((User) subject.getPrincipal()).getId(), UserOperation.TYPE_LOGIN.getType(), UserOperation.TYPE_LOGIN.getTypeName(), UserOperation.TYPE_LOGIN.getTypeNameEn()); |
| | | return response.setII(1, true, dataList, "登录成功"); |
| | | map.put("teamFlag",bjService.getGroupFlag(userInf.getId().intValue())); |
| | | CommonUtil.record( UserLogTypeEnum.CATEGORY_SYSTEM.getType(), UserLogTypeEnum.LOGIN.getType(),UserLogTypeEnum.LOGIN.getName(), UserLogTypeEnum.LOGIN.getName()); |
| | | return response.setII(1, true, map, "登录成功"); |
| | | } |
| | | return response.set(1, false,"认证未通过"); |
| | | } |
| | |
| | | if(user!=null){ |
| | | String sessionId = (String) httpSession.getServletContext().getAttribute(user.getName()); |
| | | if(httpSession.getId().equals(sessionId)){ |
| | | model.set(1,user,null); |
| | | model.set(1,user,""); |
| | | }else{ |
| | | if(sessionId.equals("123456")){ |
| | | model.set(1,false,"身份权限变更,请重新登录"); |