public ActionResult Index(LoginModel model) { if (!ModelState.IsValid) { return(View(model)); } var result = _authenticationService.Authenticate(model); if (!result.IsAuthenticated) { return(View(model)); } var token = new AccessToken(result.User.Id); _accessTokenRepository.Save(token); Response.Cookies.Add(new HttpCookie("token", token.Id) { Expires = token.Expires, Path = "/" }); return(RedirectToAction("Index", "Security")); }