public ActionResult LogIn(string returnUrl)
        {
            var model = new LogInModel
            {
                ReturnUrl = returnUrl
            };

            return View(model);
        }
 public void SignInTestEmpty()
 {
     var mockStore = new Mock<IUserStore<User, int>>();
     var userManager = new UserManager<User, int>(mockStore.Object);
     AuthController testController = new AuthController(userManager);
     LogInModel testModel = new LogInModel();
     var result = testController.LogIn(testModel) as Task<ActionResult>;
     Assert.IsTrue(result.IsFaulted);
 }
 public void SignInTestWithoutPassword()
 {
     var mockStore = new Mock<IUserStore<User, int>>();
     var userManager = new UserManager<User, int>(mockStore.Object);
     AuthController testController = new AuthController(userManager);
     LogInModel testModel = new LogInModel();
     testModel.Email = "*****@*****.**";
     var result = testController.LogIn(testModel) as Task<ActionResult>;
     Assert.IsTrue(result.IsCompleted);
 }
        public async Task<ActionResult> LogIn(LogInModel model)
        {
            if (!ModelState.IsValid)
            {
                return View();
            }

            var user = await userManager.FindAsync(model.Email, model.Password);

            if (user != null)
            {
                var identity = await userManager.CreateIdentityAsync(
                    user, DefaultAuthenticationTypes.ApplicationCookie);

                GetAuthenticationManager().SignIn(identity);

                return Redirect(GetRedirectUrl(model.ReturnUrl));
            }

            // user authN failed
            ModelState.AddModelError("", "Invalid email or password");
            return View();
        }