mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 21:16:49 +00:00
Large refactor and project restructuring
This commit is contained in:
parent
c10e197c39
commit
6d5004bf54
71 changed files with 1664 additions and 1607 deletions
23
PluralKit.API/Utils/RequiresSystemAttribute.cs
Normal file
23
PluralKit.API/Utils/RequiresSystemAttribute.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace PluralKit.API
|
||||
{
|
||||
public class RequiresSystemAttribute: ActionFilterAttribute
|
||||
{
|
||||
|
||||
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var auth = context.HttpContext.RequestServices.GetRequiredService<TokenAuthService>();
|
||||
if (auth.CurrentSystem == null)
|
||||
{
|
||||
context.Result = new UnauthorizedObjectResult("Invalid or missing token in Authorization header.");
|
||||
return;
|
||||
}
|
||||
|
||||
await base.OnActionExecutionAsync(context, next);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue