public static async Task <bool> HasAccess(this ClaimsPrincipal User, Microsoft.AspNetCore.Identity.UserManager <ApplicationUser> userManager, string access) { if (User.IsInRole("Admin")) { return(true); } var user = await userManager.FindByNameAsync(User.Identity.Name); var claims = await userManager.GetClaimsAsync(user); return(claims.Any(x => x.Value == access)); }