Exemplo n.º 1
0
  public String modifyPassWord() throws Exception {
    UserbaseinfoDAO userDao = (UserbaseinfoDAO) DAOFactory.getIUserbaseinfoDAOInstance();
    String useroldPassword = request.getParameter("myoldPassword");
    String usernewPassword = request.getParameter("mynewPassword");
    String userId = (String) ServletActionContext.getRequest().getSession().getAttribute("userId");
    String DaoUserPass = userDao.getUserAllMsgById(Integer.parseInt(userId)).getUserPassword();
    boolean Istrue = true;
    boolean Isrepeat = true;
    MessageDigest md5 = MessageDigest.getInstance("MD5");
    byte[] md = md5.digest(useroldPassword.getBytes());
    useroldPassword = new String(md);
    byte[] md1 = md5.digest(usernewPassword.getBytes());
    usernewPassword = new String(md1);

    // 如果旧密码与数据库密码不匹配,提示用户错误消息
    if (!DaoUserPass.equals(useroldPassword)) {
      Istrue = false;
    } else {
      // 比较新密码与原始密码是否一致,如果一致,提示用户新密码与旧密码不能一致
      if (!DaoUserPass.equals(usernewPassword) && usernewPassword != "") { // 如果不一致,修改数据库中的密码
        Isrepeat = false; // 没有重复
        System.out.println("用户id=" + userId + "用户新密码=" + usernewPassword);
        DAOFactory.getIUserbaseinfoDAOInstance()
            .updatePassword(Integer.parseInt(userId), usernewPassword);
      }
    }
    System.out.println(Istrue + "            " + Isrepeat);
    response.getWriter().print("[{\"isTrue\":" + Istrue + "},{\"isRepeat\":" + Isrepeat + "}]");
    return null;
  }
Exemplo n.º 2
0
 public String showInformation() throws IOException {
   int userId = Integer.parseInt((String) request.getSession().getAttribute("userId"));
   Userbaseinfo userBase =
       (Userbaseinfo) DAOFactory.getIUserbaseinfoDAOInstance().getUserAllMsgById(userId);
   String userIntr = userBase.getUserIntroduct() == null ? "" : userBase.getUserIntroduct();
   String info =
       ("{\"userName\":\""
           + userBase.getNickName()
           + "\",\"userSex\":"
           + userBase.getUserSex()
           + ",\"userEmail\":\""
           + userBase.getUserEmail()
           + "\",\"userImg\":\""
           + userBase.getHeadimage()
           + "\",\"userJob\":\""
           + userBase.getUserProf()
           + "\",\"userAddress\":\""
           + userBase.getUserAddress()
           + "\",\"userNumber\":\""
           + userBase.getPhoneNumber()
           + "\",\"userSelfInformation\":\""
           + userIntr
           + "\"}");
   request.setAttribute("information", info);
   return "toShow";
 }
Exemplo n.º 3
0
  /** @return */
  public String checkLogin() {
    String account = userLoginModel.getAccount();
    String oldPassword = userLoginModel.getPassword();
    String DBPassword;
    String DBId;
    String nickName;
    String DBModel = DAOFactory.getIUserbaseinfoDAOInstance().getPasswordByAccount(account);

    try {
      MessageDigest md5 = MessageDigest.getInstance("MD5");
      byte[] md = md5.digest(oldPassword.getBytes());
      oldPassword = new String(md);
    } catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
    }

    if (DBModel == null) {
      request.setAttribute("errorContent", "账号不存在!");
      return "toLogin";
    } else {
      DBPassword = (DBModel.split(","))[0];
      DBId = (DBModel.split(","))[1];

      nickName = (DBModel.split(","))[2];
      if (!findOnlineUser(DBId)) {
        request.setAttribute("errorContent", "此账号已在其他地方登陆,请先退出再重新登陆!");
        return "toLogin";
      }
      if (DBPassword.equals(oldPassword)) {

        ServletActionContext.getRequest().getSession().setAttribute("userId", DBId);
        ServletActionContext.getRequest().getSession().setAttribute("nickName", nickName);
        if (!DAOFactory.getIUserbaseinfoDAOInstance().isTested(Integer.parseInt(DBId))) {
          return "toSurvey";
        }
        DAOFactory.getIUserbaseinfoDAOInstance().updateLoginTime(Integer.parseInt(DBId));
        return "toPersonSpace";
      }
      request.setAttribute("errorContent", "密码错误!");
      return "toLogin";
    }
  }
Exemplo n.º 4
0
 public String updateMsgMail() {
   int userId = Integer.parseInt((String) request.getSession().getAttribute("userId"));
   UserbaseinfoDAO userDAO = (UserbaseinfoDAO) DAOFactory.getIUserbaseinfoDAOInstance();
   userDAO.updateUserMsgMail(user, userId);
   try {
     showInformation();
   } catch (IOException e) {
     e.printStackTrace();
   }
   return "toUpdate";
 }
Exemplo n.º 5
0
 /*
  * 检查对应账号的用户是否存在
  */
 public String checkAccount() throws Exception {
   String existMsg = "{\"isExist\":";
   String userAccountNo = request.getParameter("accountNo");
   // System.out.println("登陆:用户昵称="+user.getNickName()+"用户密码="+user.getUserPassword()+userD.nickNameExist(user.getNickName()));
   if (-1 == userAccountNo.indexOf("@")) {
     // 是手机
     if (!DAOFactory.getIUserbaseinfoDAOInstance().phoneNoExist(userAccountNo)) {
       existMsg += false + "}";
     } else {
       existMsg += true + "}";
     }
   } else {
     if (!DAOFactory.getIUserbaseinfoDAOInstance().emailNoExist(userAccountNo)) {
       existMsg += false + "}";
     } else {
       existMsg += true + "}";
     }
   }
   response.getWriter().print(existMsg);
   return null;
 }
Exemplo n.º 6
0
 public String checkUser() throws Exception {
   String existMsg = "{\"isExist\":";
   request.setCharacterEncoding("UTF-8");
   String userNickName = request.getParameter("nickName");
   if (!DAOFactory.getIUserbaseinfoDAOInstance().nickNameExist(userNickName)) {
     existMsg += false + "}";
   } else {
     existMsg += true + "}";
   }
   response.getWriter().print(existMsg);
   return null;
 }
Exemplo n.º 7
0
  public String forgetThird() {
    String newPassword = request.getParameter("newPassword");
    String account = (String) request.getSession().getAttribute("account");
    try {
      MessageDigest md5 = MessageDigest.getInstance("MD5");
      byte[] md = md5.digest(newPassword.getBytes());
      newPassword = new String(md);
    } catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
    }

    DAOFactory.getIUserbaseinfoDAOInstance().setPasswordByAccount(account, newPassword);
    return "toLogin";
  }
 @Override
 public String execute() throws Exception {
   HttpSession session = request.getSession();
   IUserbaseinfoDAO userDao = DAOFactory.getIUserbaseinfoDAOInstance();
   int userId = Integer.parseInt(session.getAttribute("userId").toString());
   // TODO 判断当前用户的积分是否足够下载
   if (userDao.getUserScore(userId) >= getCodeScore()) {
     DAOFactory.getICodeInfoDAOInstance().addDownNo(getCodeId());
     userDao.updateNo("userScore", userId, false, getCodeScore());
     userDao.updateNo("userScore", userDao.getId(getCodeUser()), true, getCodeScore());
     return SUCCESS;
   } else {
     // 提醒用户积分不够,不能下载,中断下载过程
     //    		response.sendRedirect("CodeInfo_getViewCodeMsg?codeId=getCodeId()");
     return "stop";
   }
 }
Exemplo n.º 9
0
  public String forgetFirst() {
    String account = forgetModel.getAccount();
    String verify = forgetModel.getVerify();
    String DBModel = DAOFactory.getIUserbaseinfoDAOInstance().getPasswordByAccount(account);
    String sessionVerify = (String) request.getSession().getAttribute("verify");

    if (DBModel == null) {
      request.setAttribute("reg", "账号不存在!");
      return "toforgetPassword1";
    } else {
      if ((sessionVerify.toLowerCase()).equals((verify.toLowerCase()))) {
        request.getSession().setAttribute("account", account);
        return "toforgetPassword2";
      }
      request.setAttribute("reg", "验证码错误!");
      return "toforgetPassword1";
    }
  }
Exemplo n.º 10
0
 public String submitSurvey() throws IOException {
   int userId = Integer.parseInt((String) request.getSession().getAttribute("userId"));
   DAOFactory.getIUserbaseinfoDAOInstance().insertSurvey(userId, this.resSurvey);
   DAOFactory.getIUserbaseinfoDAOInstance().updateLoginTime(userId);
   return null;
 }
Exemplo n.º 11
0
 public String insertUser() throws Exception {
   userInfo = voToPo(urm);
   return DAOFactory.getIUserbaseinfoDAOInstance().insertUser(userInfo) ? "toLogin" : "toRegister";
 }