public void LoginFromHome_CurrentWizardStep3Test()
        {
            // Arrange
            mockWebSecurity.Setup(s => s.Login("user4", "password", false)).Returns(true);
            var model = new LoginModel { UserName = "******", Password = "******" };

            // Act
            RedirectToRouteResult result = controller.Login(model, null) as RedirectToRouteResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual<string>("Setup", result.RouteValues["controller"].ToString());
            Assert.AreEqual<string>("RealEstate", result.RouteValues["action"].ToString());
        }
        public void LoginFromHome_WizardComplete_StatisticsPage()
        {
            // Arrange
            mockWebSecurity.Setup(s => s.Login("user2", "password", false)).Returns(true);
            var model = new LoginModel { UserName = "******", Password = "******" };

            // Act
            RedirectToRouteResult result = controller.Login(model, null) as RedirectToRouteResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual<string>("Statistics", result.RouteValues["controller"].ToString());
            Assert.AreEqual<string>("Index", result.RouteValues["action"].ToString());
        }
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && webSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                // if logging in from main page, redirect to setup if new user, or statistics if existing user
                if (returnUrl == null)
                {
                    return LoginFromHomeRedirect(model.UserName);
                }
                else
                {
                    return RedirectToLocal(returnUrl);
                }
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }