public async Task <IActionResult> PostLogin([FromBody] SysUser json) { if (json != null) { HashingService hserv = new HashingService(json.UserId, json.UserPassword); bool found = ameritus1_angularContext.SysUser.Any(f => f.FirstName == json.FirstName && f.LastName == json.LastName && hserv.IsMatchingUserName(HashingService.ToHash(f.UserId), HashingService.ToSalt(f.UserId)) && hserv.IsMatchingUserPassword(HashingService.ToHash(f.UserPassword), HashingService.ToSalt(f.UserPassword))); if (found) { var claims = new List <Claim> { new Claim(ClaimTypes.Name, json.UserId) }; ClaimsIdentity userIdentity = new ClaimsIdentity(claims, "login"); ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity); await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTime.UtcNow.AddMinutes(HomeController.EXPIRY) }); return(Json("Success")); } else { return(Json("Invalid credentials")); } } else { return(Json("An unknown error has occurred")); } }