/**
  * Description:进行手机认证<br>
  *
  * @author justin.xu
  * @version 0.1 2014年4月30日
  * @param request
  * @param session
  * @param mobile 手机号
  * @param activeCode 验证码
  * @return String
  */
 @RequestMapping(value = "activeMobile")
 @ResponseBody
 public MessageBox activeMobile(
     HttpServletRequest request, HttpSession session, String mobile, String activeCode) {
   String result = "success";
   try {
     ShiroUser shiroUser = currentUser();
     MobileApproVo mobileApproVo =
         mobileApproService.queryMobileApproByUserId(shiroUser.getUserId());
     // 修改手机号码操作
     if (null != mobileApproVo
         && null != mobileApproVo.getPassed()
         && mobileApproVo.getPassed() == Constants.YES) {
       return new MessageBox("0", "手机号码已认证通过");
     }
     MemberCnd memberCnd = new MemberCnd();
     memberCnd.setId(shiroUser.getUserId());
     MemberVo memberVo = memberService.queryMemberByCnd(memberCnd);
     result =
         mobileApproService.saveMobileAppro(
             memberVo, mobile, activeCode, request, BusinessConstants.MOBILE_APPRO_FUNCTION);
   } catch (AppException ae) {
     result = ae.getMessage();
   } catch (Exception e) {
     result = "网络连接异常,请刷新页面或稍后重试!";
     e.printStackTrace();
   }
   if (BusinessConstants.SUCCESS.equals(result)) {
     return new MessageBox("1", "短信认证成功!");
   }
   return new MessageBox("0", result);
 }
  /**
   * Description:进行手机认证<br>
   *
   * @author hujianpan
   * @version 0.1 2014年8月30日
   * @param request
   * @param session
   * @param mobile 手机号
   * @param activeCode 验证码
   * @return String
   */
  @RequestMapping(value = "verificationMobailActiveCode")
  @ResponseBody
  public MessageBox verificationMobailActiveCode(HttpServletRequest request, HttpSession session) {
    String result = BusinessConstants.SUCCESS;
    Member member = currentMember();
    String userNameParam = "@@@@";
    String mobileParam = request.getParameter("mobile");
    String activeCodeParam = request.getParameter("activeCode");
    if (member != null) {
      userNameParam = member.getUsername();
      if (StringUtils.isEmpty(userNameParam)) {
        return new MessageBox("0", "用户名不能为空");
      }
    } else {
      return new MessageBox("0", "注册信息丢失,请重新登入或注册");
    }

    if (StringUtils.isEmpty(mobileParam)) {
      return new MessageBox("0", "用户手机号不能为空");
    }
    if (StringUtils.isEmpty(activeCodeParam)) {
      return new MessageBox("0", "手机验证码不能为空");
    }

    result =
        mobileApproService.verificationMobailActiveCode(
            request, member, mobileParam, activeCodeParam);
    if (!BusinessConstants.SUCCESS.equals(result)) {
      return new MessageBox("0", result);
    }

    return new MessageBox("1", "验证成功");
  }
Exemplo n.º 3
0
  /**
   * Description:手机短信验证码<br>
   *
   * @author yubin
   * @version 0.1 2015年9月18日
   * @return MessageBox
   */
  @RequestMapping(value = "/isMobileCode")
  public @ResponseBody MessageBox isMobileCode() {
    String result = "success";
    try {
      String mobileCode = currentRequest().getParameter("mobileCode");
      String mobileNum = currentRequest().getParameter("mobileNum");
      if (null == mobileCode) {
        return new MessageBox("0", "请输入手机验证码");
      }
      if (null != mobileCode && !"".equals(mobileCode.trim())) {
        // 验证手机验证码是否输入正确
        // 验证验证码是否正确
        String valiateResult =
            phoneService.compareSmsValidate(
                mobileNum, mobileCode, BusinessConstants.MOBILE_APPRO_FUNCTION);
        if (valiateResult != "success") {
          return new MessageBox("0", valiateResult);
        }
      }

    } catch (Exception e) {
      result = "failer";
      logger.error("手机验证码错误");
    }
    if (!BusinessConstants.SUCCESS.equals(result)) {
      return new MessageBox("0", result);
    }

    return new MessageBox("1", result);
  }
 /**
  * Description:修改绑定手机时,对原来的手机号码认证<br>
  *
  * @author hujianpan
  * @version 0.1 2014年4月30日
  * @param request
  * @param session
  * @param mobile 手机号
  * @param activeCode 验证码
  * @return String
  */
 @RequestMapping(value = "verifyCurrentUserMobile")
 @ResponseBody
 public MessageBox verifyCurrentUserMobile(
     HttpServletRequest request, HttpSession session, String mobile, String activeCode) {
   String result = "success";
   ShiroUser shiroUser = currentUser();
   try {
     MemberCnd memberCnd = new MemberCnd();
     memberCnd.setId(shiroUser.getUserId());
     MemberVo memberVo = memberService.queryMemberByCnd(memberCnd);
     memberVo.setIsModify(true);
     result =
         mobileApproService.saveMobileAppro(
             memberVo,
             mobile,
             activeCode,
             request,
             BusinessConstants.MOBILE_APPRO_RESET_FUNCTION,
             BusinessConstants.SMS_TEMPLATE_TYPE_VERIFYSUCCESS_MOBILE_CODE);
   } catch (AppException ae) {
     result = ae.getMessage();
   } catch (Exception e) {
     result = "网络连接异常,请刷新页面或稍后重试!";
     e.printStackTrace();
   }
   if (BusinessConstants.SUCCESS.equals(result)) {
     // 记录到session中,代表验证原有手机通过
     session.setAttribute(
         BusinessConstants.MOBILE_APPRO_RESET_FUNCTION + shiroUser.getUserId(), "true");
     return new MessageBox("1", "短信认证成功!");
   }
   return new MessageBox("0", result);
 }
Exemplo n.º 5
0
  /**
   * Description:判断手机号码是否存在<br>
   *
   * @author yubin
   * @version 0.1 2015年9月17日
   * @param memberRegisterCnd
   * @param request
   * @param session
   * @return MessageBox
   */
  @RequestMapping(value = "/isMobileNumExist")
  public @ResponseBody MessageBox isMobileNumExist(String mobileNum) {
    String result = "success";
    try {

      if (null != mobileNum && !"".equals(mobileNum.trim())) {
        // 验证手机号是否存在
        MobileApproCnd mobileApproCnd = new MobileApproCnd();
        mobileApproCnd.setMobileNum(mobileNum);
        Integer usernameCount = mobileApproMapper.queryRepeatMobileApproCount(mobileApproCnd);
        if (null != usernameCount && usernameCount > 0) {
          return new MessageBox("2", "该手机号已经被使用!");
        }
      }

    } catch (Exception e) {
      result = "failer";
      logger.error("该手机号已经被使用!");
    }
    if (!BusinessConstants.SUCCESS.equals(result)) {
      return new MessageBox("0", result);
    }

    return new MessageBox("1", result);
  }
Exemplo n.º 6
0
  /**
   * Description:找回密码第一步<br>
   *
   * @author yubin
   * @version 0.1 2015年12月29日
   * @param mobileNum
   * @return MessageBox
   */
  @RequestMapping(value = "/findMobileByOne")
  public @ResponseBody MessageBox findMobileByOne(String mobileNum, String validatecode) {
    String result = "success";
    try {

      if (null != mobileNum && !"".equals(mobileNum.trim())) {
        MobileApproCnd mobileApproCnd = new MobileApproCnd();
        mobileApproCnd.setMobileNum(mobileNum);
        Integer usernameCount = mobileApproMapper.queryRepeatMobileApproCount(mobileApproCnd);
        if (usernameCount == null || usernameCount.intValue() < 1) {
          return new MessageBox("0", "您的手机号码没有绑定账号");
        }
      }
      String randCode = (String) currentSession().getAttribute("randomCode");
      if (null == validatecode || null == randCode || !validatecode.equals(randCode)) {
        return new MessageBox("0", "验证码输入有误!");
      }

    } catch (Exception e) {
      result = "failer";
      logger.error("找回密码第一步:", e);
    }
    if (!BusinessConstants.SUCCESS.equals(result)) {
      return new MessageBox("0", result);
    }

    return new MessageBox("1", result);
  }
  /**
   * Description:安全中心-验证账户信息-发送手机认证验证码<br>
   *
   * @author hujianpan
   * @version 0.1 2014年8月30日
   * @param request
   * @param session
   * @return String
   */
  @RequiresAuthentication
  @RequestMapping(value = "/sendMobailActiveInSaftCenter")
  @ResponseBody
  public MessageBox sendMobailActiveInSaftCenter(HttpServletRequest request, HttpSession session) {
    String result = BusinessConstants.SUCCESS;
    Member member = currentMember();
    if (StringUtils.isEmpty(member.getUsername())) {
      return new MessageBox("0", "请先登入!");
    }
    String mobile = request.getParameter("mobile");
    String activeCode = request.getParameter("activeCode");
    try {
      MobileApproVo mobileApproVo = mobileApproService.queryMobileApproByUserId(member.getId());
      // 修改手机号码操作
      if (null
              == session.getAttribute(
                  BusinessConstants.MOBILE_APPRO_RESET_FUNCTION + member.getId())
          && (null != mobileApproVo
              && null != mobileApproVo.getPassed()
              && mobileApproVo.getPassed() == Constants.YES)) {
        return new MessageBox("0", "手机号码已认证通过");
      }
      result =
          mobileApproService.sendMobileApprValidate(
              mobile, request, member.getUsername(), BusinessConstants.MOBILE_APPRO_FUNCTION);
      if (!BusinessConstants.SUCCESS.equals(result)) {
        return new MessageBox("0", result);
      }
      ShiroUser shiroUser = currentUser();
      MemberVo memberVo = new MemberVo();
      memberVo.setId(shiroUser.getUserId());

      mobileApproService.packageMobileApproCode(memberVo, mobile, activeCode, request);
      // 删除验证原有手机号码session
      session.removeAttribute(BusinessConstants.MOBILE_APPRO_RESET_FUNCTION + member.getId());
    } catch (Exception e) {
      result = "发送验证码出错,请联系客服";
      e.printStackTrace();
    }
    if (!BusinessConstants.SUCCESS.equals(result)) {
      return new MessageBox("0", result);
    }
    return new MessageBox("1", "发送成功,请注意查收");
  }
  /**
   * Description:进行手机认证<br>
   *
   * @author hujianpan
   * @version 0.1 2014年8月30日
   * @param request
   * @param session
   * @param mobile 手机号
   * @param activeCode 验证码
   * @return String
   */
  @RequestMapping(
      value = "/jsonpVerificationMobail",
      produces = {"text/plain;charset=UTF-8"})
  @ResponseBody
  public String verificationMobailActiveCodeJsonp(
      HttpServletRequest request, HttpSession session, String jsonpcallback) {
    MessageBox box = null;
    String result = BusinessConstants.SUCCESS;
    Member member = currentMember();
    String userNameParam = "@@@@";
    String mobileParam = request.getParameter("mobile");
    String activeCodeParam = request.getParameter("activeCode");
    if (member != null) {
      userNameParam = member.getUsername();
      if (StringUtils.isEmpty(userNameParam)) {
        box = new MessageBox("0", "用户名不能为空");
        return jsonpcallback + "(" + JsonUtils.bean2Json(box) + ")";
      }
    } else {
      box = new MessageBox("0", "注册信息丢失,请重新登入或注册");
      return jsonpcallback + "(" + JsonUtils.bean2Json(box) + ")";
    }

    if (StringUtils.isEmpty(mobileParam)) {
      box = new MessageBox("0", "用户手机号不能为空");
      return jsonpcallback + "(" + JsonUtils.bean2Json(box) + ")";
    }
    if (StringUtils.isEmpty(activeCodeParam)) {

      box = new MessageBox("0", "手机验证码不能为空");
      return jsonpcallback + "(" + JsonUtils.bean2Json(box) + ")";
    }

    result =
        mobileApproService.verificationMobailActiveCode(
            request, member, mobileParam, activeCodeParam);
    if (!BusinessConstants.SUCCESS.equals(result)) {
      box = new MessageBox("0", result);
      return jsonpcallback + "(" + JsonUtils.bean2Json(box) + ")";
    }

    box = new MessageBox("1", "验证成功");
    return jsonpcallback + "(" + JsonUtils.bean2Json(box) + ")";
  }
  /**
   * Description:注册-验证账户信息-发送手机认证验证码<br>
   *
   * @author hujianpan
   * @version 0.1 2014年8月30日
   * @param request
   * @param session
   * @return String
   */
  @RequestMapping(value = "/sendMobailActiveByMessage")
  @ResponseBody
  public MessageBox sendMobailActiveByMessage(HttpServletRequest request, HttpSession session) {
    try {
      String result = BusinessConstants.SUCCESS;
      Member member = currentMember();

      if (null == member || StringUtils.isEmpty(member.getUsername())) {
        return new MessageBox("0", "未关联到要绑定的用户!");
      }
      result = mobileApproService.sendMobailMessageActiveCode(request, member);
      if (!BusinessConstants.SUCCESS.equals(result)) {
        return new MessageBox("0", result);
      }
      return new MessageBox("1", "发送成功,请注意查收");
    } catch (Exception e) {
      logger.error("注册-验证账户信息-发送手机认证验证码出错", e);
      return new MessageBox("0", "发送异常");
    }
  }
Exemplo n.º 10
0
  /**
   * Description:检查用户名或邮箱或推荐人是否存在<br>
   *
   * @author justin.xu
   * @version 0.1 2014年4月22日
   * @param memberRegisterCnd
   * @return String
   */
  @RequestMapping(value = "/isInviterNameExist")
  public @ResponseBody MessageBox isInviterNameExist(
      MemberRegisterCnd memberRegisterCnd, HttpServletRequest request, HttpSession session) {
    String result = "success";
    try {
      String inviterName = request.getParameter("inviterName");
      memberRegisterCnd.setInviterName(inviterName);
      result = memberRegisterService.queryMemberRepeat(memberRegisterCnd, null);

    } catch (Exception e) {
      result = "failer";
      logger.error("验证用户名或邮箱是否存在错误");
      e.printStackTrace();
    }
    if (!BusinessConstants.SUCCESS.equals(result)) {
      return new MessageBox("0", result);
    }

    return new MessageBox("1", result);
  }
Exemplo n.º 11
0
  /**
   * Description:发送邮箱验证信息<br>
   *
   * @author hujianpan
   * @version 0.1 2014年8月30日
   * @param request
   * @return String
   */
  @RequestMapping(value = "sendEmailVerifyLink")
  @ResponseBody
  public MessageBox sendEmailVerifyLink(HttpServletRequest request) {
    String destinationEmail = request.getParameter("email");
    Boolean again = Boolean.valueOf(request.getParameter("again")); //
    Member member = currentMember();
    if (null == member || StringUtils.isEmpty(member.getUsername())) {
      return MessageBox.build("0", "发送验证邮箱时出错,当前用户可能已验证,请核对。");
    }
    String result = "";
    try {
      result =
          memberRegisterService.sendEmailLinkActivateMember(
              request, destinationEmail, again, member);
    } catch (Exception e) {
      return MessageBox.build("0", e.getMessage());
    }
    if (!BusinessConstants.SUCCESS.equals(result)) {
      return MessageBox.build("0", result);
    }

    return MessageBox.build("1", "发送验证邮件成功,请去激活!");
  }
 /**
  * Description:根据当前用户的手机号发送验证码<br>
  *
  * @author justin.xu
  * @version 0.1 2014年4月30日
  * @param request
  * @param session
  * @return String
  */
 @RequestMapping(value = "sendResetMsg")
 @ResponseBody
 public MessageBox sendResetMsg(HttpServletRequest request, HttpSession session) {
   String result = BusinessConstants.SUCCESS;
   try {
     ShiroUser shiroUser = currentUser();
     MobileApproVo mobileApproVo =
         mobileApproService.queryMobileApproByUserId(shiroUser.getUserId());
     result =
         mobileApproService.sendMobileApprValidate(
             mobileApproVo.getMobileNum(),
             request,
             shiroUser.getUserName(),
             BusinessConstants.MOBILE_APPRO_RESET_FUNCTION,
             BusinessConstants.SMS_TEMPLATE_TYPE_VERIFY_MOBILE_CODE);
   } catch (Exception e) {
     result = "网络连接异常,请刷新页面或稍后重试!";
     e.printStackTrace();
   }
   if (BusinessConstants.SUCCESS.equals(result)) {
     return new MessageBox("1", "验证码发送成功,请查收手机短信。");
   }
   return new MessageBox("0", result);
 }
Exemplo n.º 13
0
 /**
  * Description:手机短信验证码发送<br>
  *
  * @author yubin
  * @version 0.1 2015年9月18日
  * @return MessageBox
  */
 @RequestMapping(value = "/sendMobileCode")
 public @ResponseBody MessageBox sendMobileCode() {
   String result = "success";
   try {
     String mobileNum = currentRequest().getParameter("mobileNum");
     if (null != mobileNum && !"".equals(mobileNum.trim())) {
       // 验证码发送
       result =
           mobileApproService.sendMobileApprValidate(
               mobileNum,
               currentRequest(),
               "",
               BusinessConstants.MOBILE_APPRO_FUNCTION,
               BusinessConstants.SMS_TEMPLATE_TYPE_WX_SAFECENTER_MOBILEVALIDATE);
     }
   } catch (Exception e) {
     result = "failer";
     logger.error("网络异常");
   }
   if (!BusinessConstants.SUCCESS.equals(result)) {
     return new MessageBox("0", result);
   }
   return new MessageBox("1", result);
 }
Exemplo n.º 14
0
  /**
   * Description:检查用户名或邮箱或推荐人是否存在<br>
   *
   * @author justin.xu
   * @version 0.1 2014年4月22日
   * @param memberRegisterCnd
   * @return String
   */
  @RequestMapping(value = "/checkMemberRepeatForRegist")
  public @ResponseBody MessageBox checkMemberRepeatForRegist(
      MemberRegisterCnd memberRegisterCnd,
      HttpServletRequest request,
      String inviterName,
      HttpSession session) {
    String result = "success";
    try {
      if (!VerifyContainSpecialChar.isContainSpecialChars(memberRegisterCnd.getUsername())) {
        return new MessageBox("0", "用户名包含特殊字符串");
      }
      result = memberRegisterService.queryMemberRepeat(memberRegisterCnd, null);

    } catch (Exception e) {
      result = "failer";
      logger.error("验证用户名或邮箱是否存在错误");
      e.printStackTrace();
    }
    if (!BusinessConstants.SUCCESS.equals(result)) {
      return new MessageBox("0", result);
    }

    return new MessageBox("1", result);
  }