Esempio n. 1
0
  /** 完善邮箱 */
  public static void doFinishEmail(String email) {

    User user = User.currUser();
    if (user.getIpsStatus() != IpsCheckStatus.EMAILISNULL) {
      check();
    }

    flash.put("email", email);
    user.email = email;

    if (StringUtils.isBlank(email)) {
      flash.error("邮箱不能为空");

      finishEmail();
    }
    if (!RegexUtils.isEmail(email)) {
      flash.error("请填写正确的邮箱地址");
      finishEmail();
    }
    ErrorInfo error = new ErrorInfo();
    User.isEmailExist(email, error);

    String sql = "update t_users set email = ? where id = ?";

    int rows = 0;

    try {
      rows = JpaHelper.execute(sql, email, user.id).executeUpdate();
    } catch (Exception e) {
      JPA.setRollbackOnly();
      e.printStackTrace();
      Logger.info("更新用户邮箱时:" + e.getMessage());
      error.code = -1;
      error.msg = "对不起,由于平台出现故障,此次更新邮箱失败!";
    }
    if (rows == 0) {
      JPA.setRollbackOnly();
      error.code = -1;
      error.msg = "数据未更新";
    }
    if (error.code < 0) {
      flash.error(error.msg);

      finishEmail();
    }
    checkEmail();
  }
Esempio n. 2
0
  /**
   * 发送短信验证码
   *
   * @param mobile
   */
  public static void sendCode(String mobile) {
    ErrorInfo error = new ErrorInfo();
    flash.put("mobile", mobile);

    if (StringUtils.isBlank(mobile)) {
      flash.error("手机号码不能为空");
    }

    if (!RegexUtils.isMobileNum(mobile)) {
      flash.error("请输入正确的手机号码");
    }

    SMSUtil.sendCode(mobile, error);

    if (error.code < 0) {
      flash.error(error.msg);
    }

    flash.put("isSending", true);

    checkMobile();
  }