public static string GetUserId(ClaimsPrincipal user)
{
return user.FindFirst(OpenIdConnectConstants.Claims.Subject)?.Value?.Trim();
}
public static async Task<(bool IsAuth, string UserId)> GetUserId(this HttpContext conntext)
{
var auth = await conntext.AuthenticateAsync(OpenIddictValidationDefaults.AuthenticationScheme);
return (auth.Succeeded, GetUserId(auth.Principal));
}