Hooking up usermanager authorization

authorization
Tags: #<Tag:0x00007f78acfdab70>

#1

Hi,

is there a way to use ASP.net Core’s UserManager to authorize the Dashboard access?
I tried injecting the user manager but it is disposed of by the time it is run inside the authorizing method.
I tried the following but the user is empty:
public class CustomAuthorizationFilter : IDashboardAuthorizationFilter
{
private readonly string _policyName;

            public CustomAuthorizationFilter(string policyName)
            {
                _policyName = policyName;
            }

            public bool Authorize(DashboardContext context)
            {
                var httpContext = context.GetHttpContext();
                var authService = httpContext.RequestServices.GetRequiredService<IAuthorizationService>();
                var ReturnValue = authService.AuthorizeAsync(httpContext.User, _policyName).GetAwaiter().GetResult().Succeeded;
                return ReturnValue;
            }
        }

please help!