Finally fix indieauth, add more logging
This commit is contained in:
parent
309b4345f1
commit
72bb48341b
@ -172,14 +172,27 @@ public class IndieauthController : ControllerBase
|
||||
|
||||
public async Task<IActionResult> AuthorizeClient(IndieauthAuthorizeModel model)
|
||||
{
|
||||
// A hack for the older stuff
|
||||
if (model.GrantType is null && model.ClientId is not null && model.ClientId == "https://indieauth.com/")
|
||||
model.GrantType = "authorization_code";
|
||||
|
||||
if (model.GrantType is null)
|
||||
{
|
||||
Logger.LogInformation("IndieAuth client token authorization failure: missing grant_type");
|
||||
return BadRequest(new { Error = "invalid_request", ErrorMessage = "Missing grant_type argument" });
|
||||
}
|
||||
|
||||
if (model.GrantType != "authorization_code")
|
||||
{
|
||||
Logger.LogInformation("IndieAuth client token authorization failure: unsupported grant_type \"{grantType}\"", model.GrantType);
|
||||
return BadRequest(new { Error = "unsupported_grant_type", ErrorMessage = "Supported grant types: authorization_code" });
|
||||
}
|
||||
|
||||
if (model.Code is null || model.ClientId is null || model.RedirectUri is null)
|
||||
{
|
||||
Logger.LogInformation("IndieAuth client token authorization failure: missing parameter (code: {noCode}, clientId: {noClientId} or redirectUri: {noRedirectUri})", model.Code is null, model.ClientId is null, model.RedirectUri is null);
|
||||
return BadRequest(new { Error = "invalid_request", ErrorMessage = "Missing required parameters" });
|
||||
}
|
||||
|
||||
var requestCode = await DbContext.IndieauthRequests.SingleOrDefaultAsync(
|
||||
c => c.Value == model.Code
|
||||
|
Loading…
Reference in New Issue
Block a user