| 6 | namespace Aptabase.Features.Stats; |
| 7 | |
| 8 | public class HasReadAccessToApp : ActionFilterAttribute |
| 9 | { |
| 10 | public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next) |
| 11 | { |
| 12 | var db = context.HttpContext.RequestServices.GetService<IDbContext>() ?? throw new InvalidOperationException("Could not get database context."); |
| 13 | var user = context.HttpContext.GetCurrentUserIdentity(); |
| 14 | var appId = context.HttpContext.Request.Query["AppId"].ToString(); |
| 15 | |
| 16 | var hasAccess = await db.HasReadAccessToApp(appId, user, context.HttpContext.RequestAborted); |
| 17 | if (!hasAccess) |
| 18 | { |
| 19 | context.Result = new StatusCodeResult(403); |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | await next(); |
| 24 | } |
| 25 | } |
nothing calls this directly
no outgoing calls
no test coverage detected