public ActionResult LogIn(LogInViewModel model) { if(!ModelState.IsValid) { return View(); } //Don't do this in production if( model.Email == "*****@*****.**" && model.Password == "password") { ClaimsIdentity identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "Ben"), new Claim(ClaimTypes.Email, "*****@*****.**"), new Claim(ClaimTypes.Country, "England") }, "ApplicationCookie"); IOwinContext ctx = Request.GetOwinContext(); IAuthenticationManager authManager = ctx.Authentication; authManager.SignIn(identity); return Redirect(GetRedirectUrl(model.ReturnUrl)); } //User authentication failed ModelState.AddModelError("", "Invalid email or password"); return View(); }
public ActionResult LogIn(string returnUrl) { var model = new LogInViewModel { ReturnUrl = returnUrl }; return View(model); }