public ActionResult Login(UserModel model) { if (model != null) { if (userService.LoginByUsernameAndPassword(model.Username, model.Password).Result) { var user = userService.GetByUsername(model.Username); var claims = ClaimHelper.GetListFromObject(user); var claimIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var authProperties = new AuthenticationProperties(); HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimIdentity), authProperties); return(Json(new { result = "Valid", message = Url.Action("Index", "Dashboard") })); } else { return(Json(new { result = "Invalid", message = "Tên Đăng Nhập Hoặc Mật Khẩu Không Hợp Lệ" })); } } else { return(Json(new { result = "Invalid", message = "" })); } }