MCPcopy Create free account
hub / github.com/aptabase/aptabase / HasReadAccessToApp

Class HasReadAccessToApp

src/Features/Stats/HasReadAccessToAppFilter.cs:8–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6namespace Aptabase.Features.Stats;
7
8public 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected