Test: Google oauth
This commit is contained in:
22
src/Web/Endpoints/Google.cs
Normal file
22
src/Web/Endpoints/Google.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user