feat(backend): add RequestDiscordTokenAsync method
This commit is contained in:
parent
2a7bd746aa
commit
6186eda092
12 changed files with 230 additions and 22 deletions
|
@ -6,12 +6,16 @@ using NodaTime;
|
|||
namespace Foxnouns.Backend.Controllers.Authentication;
|
||||
|
||||
[Route("/api/v2/auth")]
|
||||
public class AuthController(Config config, KeyCacheService keyCacheSvc) : ApiControllerBase
|
||||
{
|
||||
public class AuthController(Config config, KeyCacheService keyCacheSvc, ILogger logger) : ApiControllerBase
|
||||
{
|
||||
[HttpPost("urls")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(UrlsResponse))]
|
||||
[ProducesResponseType<UrlsResponse>(StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> UrlsAsync()
|
||||
{
|
||||
logger.Debug("Generating auth URLs for Discord: {Discord}, Google: {Google}, Tumblr: {Tumblr}",
|
||||
config.DiscordAuth.Enabled,
|
||||
config.GoogleAuth.Enabled,
|
||||
config.TumblrAuth.Enabled);
|
||||
var state = HttpUtility.UrlEncode(await keyCacheSvc.GenerateAuthStateAsync());
|
||||
string? discord = null;
|
||||
if (config.DiscordAuth.ClientId != null && config.DiscordAuth.ClientSecret != null)
|
||||
|
@ -35,4 +39,6 @@ public class AuthController(Config config, KeyCacheService keyCacheSvc) : ApiCon
|
|||
string Token,
|
||||
Instant ExpiresAt
|
||||
);
|
||||
|
||||
public record CallbackRequest(string Code, string State);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue