Test: Integrated google auth

This commit is contained in:
Kamigen
2024-04-29 18:30:04 -04:00
parent be1d4cb3b6
commit 025195627c
9 changed files with 22 additions and 127 deletions

View File

@@ -1,32 +0,0 @@
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 googleUser = await googleService.GetUserInfoAsync(command.AccessToken) ?? throw new Exception("Failed to get user info from Google");
var user = await userService.FindUserByEmailAsync(googleUser.Email);
if (user != null)
{
// TODO: Return login information
return await sender.Send(command);
}
await userService.CreateUserAsync(googleUser);
return await sender.Send(command);
}
}