Test: Integrated google auth
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user