当前位置: 首页>>代码示例>>C#>>正文


C# Customer.ValidatePasswords方法代码示例

本文整理汇总了C#中Customer.ValidatePasswords方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.ValidatePasswords方法的具体用法?C# Customer.ValidatePasswords怎么用?C# Customer.ValidatePasswords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Customer的用法示例。


在下文中一共展示了Customer.ValidatePasswords方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Signup

        public ActionResult Signup() {
            Customer cust = new Customer();
            Settings settings = ViewBag.settings;
            Address billing = new Address();
            Address shipping = new Address();
            bool loginAfterRegistration = false;
            bool sameAsBilling = (Request.Form["same"] != null) ? true : false;

            if (settings.Get("CustomerLoginAfterRegistration") == "true") {
                loginAfterRegistration = true;
            }
            try {
                #region Object Instantiation
                // Build out our Customer object
                cust = new Customer {
                    email = Request.Form["email"],
                    fname = Request.Form["fname"],
                    lname = Request.Form["lname"],
                    phone = Request.Form["phone"],
                    dateAdded = DateTime.UtcNow,
                    receiveNewsletter = (Request.Form["receiveNewsletter"] != null) ? 1 : 0,
                    receiveOffers = (Request.Form["receiveOffers"] != null) ? 1 : 0,
                    isSuspended = 0,
                    isValidated = 0,
                    validator = Guid.NewGuid()
                };

                // Build out our Billing object
                billing = new Address {
                    first = Request.Form["bfirst"],
                    last = Request.Form["blast"],
                    street1 = Request.Form["bstreet1"],
                    street2 = Request.Form["bstreet2"],
                    city = Request.Form["bcity"],
                    postal_code = Request.Form["bzip"],
                    residential = (Request.Form["bresidential"] == null) ? false : true,
                    active = true
                };
                
                // Build out our Shipping object
                shipping = new Address {
                    first = Request.Form["sfirst"],
                    last = Request.Form["slast"],
                    street1 = Request.Form["sstreet1"],
                    street2 = Request.Form["sstreet2"],
                    city = Request.Form["scity"],
                    postal_code = Request.Form["szip"],
                    residential = (Request.Form["sresidential"] == null) ? false : true,
                    active = true
                };
                #endregion

                cust.ValidatePasswords(Request.Form["password"], Request.Form["password2"]);
                cust.ValidateEmail(Request.Form["email"], Request.Form["email"]);

                #region Address state validation
                // Validate billing state
                try {
                    billing.state = Convert.ToInt32(Request.Form["bstate"]);
                } catch (Exception) {
                    throw new Exception("You must select a billing state/province.");
                }
                // Validate shipping state
                if (!sameAsBilling || !billing.Equals(shipping)) {
                    try {
                        shipping.state = Convert.ToInt32(Request.Form["sstate"]);
                    } catch (Exception) {
                        throw new Exception("You must select a shipping state/province.");
                    }
                }
                #endregion

                string[] nullables = new string[] { "phone", "issuspended", "receivenewsletter", "receiveoffers", "isvalidated", "billingid", "shippingid", "Address", "Address1", "cart", "id", "orders" };
                UDF.Sanitize(cust, nullables);

                cust.Save();
                billing.Save(cust.ID);
                if (sameAsBilling || billing.Equals(shipping)) {
                    shipping = billing;
                } else {
                    shipping.Save(cust.ID);
                }
                cust.SaveAddresses(billing, shipping);
                cust.Address = billing;
                cust.Address1 = shipping;

                if (loginAfterRegistration) {
                    return RedirectToAction("login", new { email = cust.email, password = Request.Form["password"], remember = 0 });
                } else {
                    TempData["error"] = "You're account has been successfully created. Please check your e-mail to confirm your account.";
                    return RedirectToAction("Index");
                }
            } catch (Exception e) {
                if (e.Message.ToLower().Contains("a potentially dangerous")) {
                    throw new HttpException(403, "Forbidden");
                }
                TempData["customer"] = cust;
                TempData["billing"] = billing;
                TempData["shipping"] = shipping;
                TempData["same"] = sameAsBilling;
//.........这里部分代码省略.........
开发者ID:curt-labs,项目名称:CURTeCommerce,代码行数:101,代码来源:AuthenticateController.cs

示例2: ResetPassword

        public ActionResult ResetPassword() {
            HttpContext ctx = System.Web.HttpContext.Current;
            Customer cust = new Customer();
            cust.GetFromStorage(ctx);
            if (!cust.LoggedIn(ctx)) {
                return RedirectToAction("Index", "Authenticate");
            }
            string message = "";
            try {
                string current = Request.Form["current"];
                string newpw = Request.Form["new"];
                string confirm = Request.Form["confirm"];

                if (String.IsNullOrEmpty(current) || String.IsNullOrEmpty(newpw) || String.IsNullOrEmpty(confirm)) {
                    throw new Exception("You must enter all password fields. Try Again");
                }

                cust.ValidateCurrentPassword(current);

                cust.ValidatePasswords(newpw, confirm);
                cust.UpdatePassword();
                message = "Your password was successfully updated.";

            } catch (Exception e) {
                message = e.Message;
            }
            return RedirectToAction("Password", new { message = message });
        }
开发者ID:curt-labs,项目名称:CURTeCommerce,代码行数:28,代码来源:AccountController.cs


注:本文中的Customer.ValidatePasswords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。