/** 保存用户信息 */ public String save() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String msg = ""; String usemd5 = PropertiesUtil.getInstance().getProperty("system.password.save.encry"); // 数据库保存密码是否需要md5加密 String newpw = entity.getVcPassword(); if (usemd5 != null && usemd5.equalsIgnoreCase("MD5")) { newpw = Utils.getMD5String(entity.getVcPassword()); } try { entity.setVcPassword(newpw); baseUserInfoManager.save(entity); request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00101); msg = "添加用户信息[登录名:" + entity.getVcLoginName() + "]成功!"; return SUCCESS; } catch (Exception e) { logger.error(e.getMessage()); request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00004); msg = "添加用户信息[登录名:" + entity.getVcLoginName() + "]失败!"; return ERROR; } finally { commonManagerImpl.log(request, msg); } }
/** 核查旧密码合法性 */ public String checkPwd() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String oldPwd = request.getParameter("oldPwd"); LoginListener loginListener = (LoginListener) ServletActionContext.getRequest() .getSession() .getAttribute(VarConstants.LOGIN_LISTENER_KEY); String userid = loginListener.getSessionContainer().getUserInfo().getId(); TbBaseUserInfo userInfo = baseUserInfoManager.get(userid); if (Utils.getMD5String(oldPwd).equals(userInfo.getVcPassword())) { Struts2Utils.renderText("true"); } else { Struts2Utils.renderText("false"); } return null; }