add error handler middleware
This commit is contained in:
parent
41e4dda7b4
commit
7a0247b551
13 changed files with 177 additions and 46 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue