public ActionResult Register(CustomMembershipSample.Models.RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                var manager = HttpContext.GetOwinContext().GetUserManager<AppUserManager>();
                var user = new CustomMembershipSample.IdentityModels.AppUser() { Username = model.UserName, Email = model.Email };
                user.Addresses = new List<Address>();
                user.Addresses.Add(new Address() { City = model.City, State = model.State, Country = model.Country });

                // Create user with supplied credentials
                var result = manager.Create<CustomMembershipSample.IdentityModels.AppUser, int>(user, model.Password);

                if (result == IdentityResult.Success)
                {
                    // On success set the sign in cookie
                    HttpContext.GetOwinContext().Authentication.SignIn(manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie));
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", result.Errors.FirstOrDefault());
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        public ActionResult Login(CustomMembershipSample.Models.LogOnModel model, string returnUrl)
        {
            var manager = HttpContext.GetOwinContext().GetUserManager<AppUserManager>();
            var user = manager.Find(model.UserName, model.Password);

            if (user != null)
            {
                // Set auth cookie for authenticated user
                HttpContext.GetOwinContext().Authentication.SignIn(manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie));
                return RedirectToAction("Index", "Home");
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }