TODO: Login user when account already exists

This commit is contained in:
Kamigen
2024-04-28 19:52:31 -04:00
parent 3a9dbf42a1
commit be1d4cb3b6

View File

@@ -14,9 +14,18 @@ public class Google : EndpointGroupBase
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");
var googleUser = await googleService.GetUserInfoAsync(command.AccessToken) ?? throw new Exception("Failed to get user info from Google");
await userService.CreateUserAsync(user);
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);
}