Test: Google oauth

This commit is contained in:
Kamigen
2024-04-15 19:10:32 -04:00
parent b6e65b416d
commit bd2410a98e
12 changed files with 132 additions and 15 deletions

View File

@@ -0,0 +1,22 @@
using Hutopy.Application.Common.Interfaces;
using Hutopy.Application.Google.Commands;
using Hutopy.Domain.Interfaces;
namespace Hutopy.Web.Endpoints;
public class Google : EndpointGroupBase
{
public override void Map(WebApplication app)
{
app.MapGroup(this)
.MapPost(CreateGoogleUser);
}
public static async Task<Guid> CreateGoogleUser(ISender sender, CreateGoogleUserCommand command, IUserService userService, IGoogleService googleService)
{
var user = await googleService.GetUserInfoAsync(command.AccessToken) ?? throw new Exception("Failed to get user info from Google");
Console.WriteLine(user);
await userService.CreateUserAsync(user);
return await sender.Send(command);
}
}