add error handler middleware

This commit is contained in:
sam 2024-05-20 19:42:04 +02:00
parent 41e4dda7b4
commit 7a0247b551
13 changed files with 177 additions and 46 deletions

View file

@ -1,3 +1,7 @@
using Foxchat.Core;
using Foxchat.Identity.Middleware;
using Foxchat.Identity.Database.Models;
namespace Foxchat.Identity.Utils;
public static class OauthUtils
@ -20,4 +24,11 @@ public static class OauthUtils
return false;
}
}
public static Application GetApplicationOrThrow(this HttpContext context)
{
var token = context.GetToken();
if (token is not { Account: null }) throw new ApiError.Forbidden("This endpoint requires a client token.");
return token.Application;
}
}