public void OnAuthorization(AuthorizationFilterContext context) { Litentity SB = (Litentity)context.HttpContext.RequestServices.GetRequiredService <ILitentity>(); if (context.Filters.Any(item => item is IAllowAnonymousFilter)) { return; } if (!SB.status) { context.Result = new ContentResult() { StatusCode = 401, Content = "Unauthorized" } } ; if (SB.SB.User.UserType != _type) { if (!SB.status) { context.Result = new ContentResult() { StatusCode = 401, Content = $"Unauthorized only {_type.ToString()} Allowed." } } ; } } } }
public void OnAuthorization(AuthorizationFilterContext context) { Litentity SB = (Litentity)context.HttpContext.RequestServices.GetRequiredService <ILitentity>(); SB.status = true; }