public ActionResult Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } var result = AuthServiceClient.LoginUser(model.Email, model.Password); if (result) { var username = AuthServiceClient.GetUsernameFromEmail(model.Email); var identity = new ClaimsIdentity( new[] { new Claim(ClaimTypes.Name, username), }, DefaultAuthenticationTypes.ApplicationCookie, ClaimTypes.Name, ClaimTypes.Role); Authentication.SignIn(new AuthenticationProperties { IsPersistent = false }, identity); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); }