コード例 #1
0
 public ActionResult RetrievePsw(string account, string verify)
 {
     //检查验证码
     if (string.IsNullOrWhiteSpace(verify) || base.HttpContext.Session["CheckCode"].Equals(null) || !verify.Equals(base.HttpContext.Session["CheckCode"].ToString(), StringComparison.OrdinalIgnoreCase))
     {
         ModelState.AddModelError("error", LoginResult.WrongVerify.GetRemark());
     }
     else
     {
         TS_USER user = new TS_USER();
         //获取用户
         user = service.GetUser(account);
         //用户不存在
         if (user == null)
         {
             ModelState.AddModelError("error", "用户不存在");
         }
         //邮箱为空或者邮箱格式错误
         else if (string.IsNullOrWhiteSpace(user.C_EMAIL) || !RegExp.IsEmail(user.C_EMAIL))
         {
             ModelState.AddModelError("error", "邮箱不存在或邮箱格式错误!");
         }
         //密码重置
         else
         {
             string str     = user.C_ACCOUNT + "|" + Constant.RESET_PWD_TOKEN;
             string content = "http://" + Request.Url.Authority + Request.Url.Segments[0] + Request.Url.Segments[1] + "ResetPsw?str=" + str;
             MailHelper.SendMail(user.C_EMAIL, "确认重置密码!", null, content, "*****@*****.**", "woaiwobaba578");
             return(Content("<script>alert('请登陆邮箱确认重置密码!');window.location.href='../Auth/Login';</script>"));
         }
     }
     return(View());
 }
コード例 #2
0
        public void TestMethod1()
        {
            string mail   = "*****@*****.**";
            bool   result = RegExp.IsEmail(mail);

            Assert.True(result);
        }
コード例 #3
0
        /// <summary>
        /// 添加留言信息
        /// </summary>
        /// <returns></returns>
        public ActionResult AddCommentInfo()
        {
            var resultMode = new ResponseBaseModel <dynamic>
            {
                ResultCode = ResponceCodeEnum.Fail,
                Message    = "响应成功"
            };
            var checkcode = System.Web.HttpContext.Current.GetStringFromParameters("checkcode");

            if (string.IsNullOrEmpty(checkcode) || string.IsNullOrEmpty(Session["ValidateCode"]?.ToString()))
            {
                resultMode.Message = "验证码必填";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }

            var oldCode = Session["ValidateCode"];

            Session["ValidateCode"] = null;
            if (!oldCode.Equals(checkcode))
            {
                resultMode.Message = "验证码必填";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            var content       = System.Web.HttpContext.Current.GetStringFromParameters("content");
            var createTime    = DateTime.Now;
            var customerEmail = System.Web.HttpContext.Current.GetStringFromParameters("email");
            var customerName  = System.Web.HttpContext.Current.GetStringFromParameters("username");
            var customerPhone = System.Web.HttpContext.Current.GetStringFromParameters("tel");

            var    fw       = new FilterWord();
            string str      = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            var    filePath = AppConfigurationHelper.GetString("SensitiveFilePath");

            fw.DictionaryPath = str + filePath;
            fw.SourctText     = content;
            content           = fw.Filter('*');
            if (string.IsNullOrEmpty(content))
            {
                resultMode.Message = "留言内容不能为空";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            fw.SourctText = customerEmail;
            customerEmail = fw.Filter('*');
            if (string.IsNullOrEmpty(customerEmail) || !RegExp.IsEmail(customerEmail))
            {
                resultMode.Message = "邮箱内容错误";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            fw.SourctText = customerName;
            customerName  = fw.Filter('*');
            if (string.IsNullOrEmpty(customerName))
            {
                resultMode.Message = "姓名内容错误";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            fw.SourctText = customerPhone;
            customerPhone = fw.Filter('*');
            if (string.IsNullOrEmpty(customerPhone) || !RegExp.IsMobileNo(customerPhone))
            {
                resultMode.Message = "电话内容错误";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            var commentModel = new CustomercommentModel {
                Content = content, CreateTime = createTime, CustomerName = customerName, CustomerEmail = customerEmail, CustomerPhone = customerPhone, IsDel = FlagEnum.HadZore.GetHashCode(), HasDeal = FlagEnum.HadZore
            };
            var server = new CustomerCommentService();

            try
            {
                server.SaveModel(commentModel);
                resultMode.Message    = "处理成功";
                resultMode.ResultCode = ResponceCodeEnum.Success;
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
                resultMode.Message = "系统异常";
            }
            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }