public ActionResult Login(CheckoutAccountModel model, string returnUrl) { if (WebSecurity.Login(model.UserName, model.Password, persistCookie: false)) { return(RedirectToAction(returnUrl)); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } // If we got this far, something failed, redisplay form return(View("SignInOrRegister", model)); }
public ActionResult Register(CheckoutAccountModel model, string returnUrl) { try { WebSecurity.CreateUserAndAccount(model.RegisterUserName, model.RegisterPassword, propertyValues: new { CreatedOn = DateTime.Now, ModifiedOn = DateTime.Now, UserName = model.RegisterUserName }); WebSecurity.Login(model.RegisterUserName, model.RegisterPassword); return(RedirectToAction(returnUrl)); } catch (Exception e) { ModelState.AddModelError("", e.Message.ToString()); } ViewBag.ItemCount = cart.ItemCount; // If we got this far, something failed, redisplay form return(View("SignInOrRegister", model)); }