Example #1
0
        public async Task<ActionResult> LogIn(AuthenticationModel 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));
            }

            ModelState.AddModelError("", "Invalid email or password");

            return View();
        }
Example #2
0
        public ActionResult LogIn(string returnUrl)
        {
            var model = new AuthenticationModel
            {
                ReturnUrl = returnUrl
            };

            return View("~/Views/Accounts/Login.cshtml", model);
        }