public async Task <OperationResult <bool> > SignInAsync(string username, string password, string redirectUrl, HttpContext httpContext, CancellationToken cancellationToken) { var authenticationResult = await _userDataService.CheckEnteredCredentialsAsync(username, password, cancellationToken); if (authenticationResult.Successful && authenticationResult.Data) { var claims = new List <Claim> { new Claim(ClaimTypes.Name, username), new Claim(ClaimTypes.Role, "Administrators") }; var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); var now = DateTimeOffset.UtcNow; var authProperties = new AuthenticationProperties { AllowRefresh = true, ExpiresUtc = now.AddMinutes(30), IsPersistent = true, IssuedUtc = now, RedirectUri = redirectUrl }; await httpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); } return(authenticationResult); }