Beispiel #1
0
        public ActionResult AjaxFindPasswordByPhone(FormCollection form)
        {
            string validatedCode = Request["ValidatedCode"].ToString();

            if (CookieHelper.GetCookie <String>("VerifyCode").ToLower() == validatedCode.ToLower())
            {
                string customerStr = Request["CustomerID"].ToString();
                if (LoginFacade.IsExistCustomer(customerStr))//存在该用户名
                {
                    CustomerInfo customer = CustomerFacade.GetCustomerByID(customerStr);
                    if (string.IsNullOrEmpty(customer.CellPhone))
                    {
                        return(Json("不存在该用户的手机号码", JsonRequestBehavior.AllowGet));
                    }
                    if (!CustomerFacade.CheckCustomerPhoneValided(customer.SysNo))
                    {
                        return(Json("用户手机密码没有通过验证", JsonRequestBehavior.AllowGet));
                    }

                    CookieHelper.SaveCookie <string>("FindPasswordCustomerID", customerStr);
                    CookieHelper.SaveCookie <string>("FindPasswordCustomerCellPhone", customer.CellPhone);
                    CookieHelper.SaveCookie <string>("FindPasswordCustomerSysNo", customer.SysNo.ToString());
                    return(Json(customer.CellPhone, JsonRequestBehavior.AllowGet));
                }
                return(Json("不存在该用户", JsonRequestBehavior.AllowGet));
            }
            return(Json("验证码不正确", JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
 public ActionResult AjaxCheckRegisterID(string CustomerID)
 {
     if (LoginFacade.IsExistCustomer(CustomerID))
     {
         return(Json("该账户名已经被注册", JsonRequestBehavior.AllowGet));
     }
     return(Json("s", JsonRequestBehavior.AllowGet));
 }
Beispiel #3
0
        public ActionResult AjaxRegister()
        {
            var model = new RegisterVM();

            this.TryUpdateModel <RegisterVM>(model);
            var result = new AjaxResult
            {
                Success = false
            };

            //判断此CustomerID是否被注册过
            if (LoginFacade.IsExistCustomer(model.CustomerID))
            {
                result.Message = "该账户名已经被注册";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }

            if (model.Password != model.RePassword)
            {
                result.Message = "密码与确认密码不相同";
                return(Json(result, JsonRequestBehavior.AllowGet));
            }

            model.Password = HttpUtility.UrlDecode(model.Password.Replace("+", "%2b"));

            CustomerInfo item = EntityConverter <RegisterVM, CustomerInfo> .Convert(model);

            item.InitRank     = 1;
            item.CustomerName = item.CustomerID;

            //密码处理
            string encryptPassword = string.Empty;
            string password        = item.Password;
            string passwordSalt    = string.Empty;

            PasswordHelper.GetNewPasswordAndSalt(ref password, ref encryptPassword, ref passwordSalt);
            item.Password     = encryptPassword;
            item.PasswordSalt = passwordSalt;

            if (LoginFacade.CreateCustomer(item).SysNo > 0)
            {
                LoginUser lUser = new LoginUser();
                lUser.UserDisplayName = item.CustomerName;
                lUser.UserID          = item.CustomerID;
                lUser.UserSysNo       = item.SysNo;
                lUser.RememberLogin   = false;
                lUser.LoginDateText   = DateTime.Now.ToString();
                lUser.TimeoutText     = DateTime.Now.AddMinutes(int.Parse(ConfigurationManager.AppSettings["LoginTimeout"].ToString())).ToString();

                CookieHelper.SaveCookie <LoginUser>("LoginCookie", lUser);
                result.Success = true;
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            result.Message = "用户注册失败,请稍后重试";
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public ActionResult AjaxCheckFindPasswordForCustomer(FormCollection form)
        {
            string validatedCode = Request["ValidatedCode"].ToString();

            if (CookieHelper.GetCookie <String>("VerifyCode").ToLower() == validatedCode.ToLower())
            {
                string customerStr = Request["CustomerID"].ToString();
                if (LoginFacade.IsExistCustomer(customerStr))//存在该用户名
                {
                    CustomerInfo customer = CustomerFacade.GetCustomerByID(customerStr);
                    if (string.IsNullOrEmpty(customer.Email))
                    {
                        return(Json("该用户没有绑定邮箱地址", JsonRequestBehavior.AllowGet));
                    }

                    //邮箱是否被验证
                    if (customer.IsEmailConfirmed != 1)
                    {
                        return(Json("对不起,您的邮箱还没有通过验证,请使用其他方式找回密码!", JsonRequestBehavior.AllowGet));
                    }
                    CookieHelper.SaveCookie <string>("FindPasswordCustomerID", customerStr);
                    //string customerid = CookieHelper.GetCookie<String>("FindPasswordCustomerID");
                    string imgBaseUrl = ConfigurationManager.AppSettings["CDNWebDomain"].ToString();//图片根目录
                    string domain     = ConfigurationManager.AppSettings["WebDomain"].ToString();
                    LoginFacade.SendFindPasswordMail(customerStr, imgBaseUrl, domain);
                    string email   = customer.Email;
                    int    x       = email.IndexOf("@");
                    string account = email.Substring(0, x);
                    if (account.Length > 1)
                    {
                        account = account.Substring(1, account.Length - 1);
                    }
                    email = email.Replace(account, "******");
                    return(Json(email, JsonRequestBehavior.AllowGet));
                }
                return(Json("不存在该用户", JsonRequestBehavior.AllowGet));
            }
            return(Json("验证码不正确", JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        public ActionResult AjaxRegister()
        {
            var model = new RegisterVM();

            this.TryUpdateModel <RegisterVM>(model);
            //if (CookieHelper.GetCookie<String>("VerifyCode").ToLower() == model.ValidatedCode.ToLower())
            //{
            if (model.Password != model.RePassword)
            {
                return(Json("密码与确认密码不相同", JsonRequestBehavior.AllowGet));
            }

            model.Password = HttpUtility.UrlDecode(model.Password.Replace("+", "%2b"));

            CustomerInfo item = EntityConverter <RegisterVM, CustomerInfo> .Convert(model);

            item.InitRank     = 1;
            item.CustomerName = item.CustomerID;
            //if (!CheckPasswordPolicy(item.Password))
            //    return Json("密码格式不正确,密码必须是字母与数据的组合", JsonRequestBehavior.AllowGet);

            if (LoginFacade.IsExistCustomer(item.CustomerID))
            {
                return(Json(new JsonResult()
                {
                    ContentType = "f", Data = "该账户名已经被注册"
                }, JsonRequestBehavior.AllowGet));
            }
            if (LoginFacade.IsCustomerEmailExist(item.Email))
            {
                return(Json(new JsonResult()
                {
                    ContentType = "f", Data = "该邮箱已经被注册"
                }, JsonRequestBehavior.AllowGet));
            }

            //密码处理
            string encryptPassword = string.Empty;
            string password        = item.Password;
            string passwordSalt    = string.Empty;

            PasswordHelper.GetNewPasswordAndSalt(ref password, ref encryptPassword, ref passwordSalt);
            item.Password     = encryptPassword;
            item.PasswordSalt = passwordSalt;

            if (LoginFacade.CreateCustomer(item).SysNo > 0)
            {
                LoginUser lUser = new LoginUser();
                lUser.UserDisplayName = item.CustomerName;
                lUser.UserID          = item.CustomerID;
                lUser.UserSysNo       = item.SysNo;
                lUser.RememberLogin   = false;
                lUser.LoginDateText   = DateTime.Now.ToString();
                lUser.TimeoutText     = DateTime.Now.AddMinutes(int.Parse(ConfigurationManager.AppSettings["LoginTimeout"].ToString())).ToString();

                CookieHelper.SaveCookie <LoginUser>("LoginCookie", lUser);

                //更新数据

                bool result = CustomerFacade.UpdateCellPhoneCustomerSysNoByID(int.Parse(model.CellPhoneCode), lUser.UserSysNo);
                return(Json(new JsonResult()
                {
                    ContentType = "s", Data = lUser.UserSysNo
                }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new JsonResult()
            {
                ContentType = "f", Data = "用户注册失败,请稍后重试"
            }, JsonRequestBehavior.AllowGet));
            //}
            //return Json(new JsonResult() { ContentType = "y", Data = "验证码不正确" }, JsonRequestBehavior.AllowGet);
        }