add password-based login endpoint

This commit is contained in:
sam 2024-05-20 21:59:30 +02:00
parent 7959b64fe6
commit 656eec81d8
5 changed files with 40 additions and 21 deletions

View file

@ -71,6 +71,13 @@ public static class HttpContextExtensions
return token as Token;
return null;
}
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;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]