TODO: Login user when account already exists
This commit is contained in:
@@ -14,9 +14,18 @@ public class Google : EndpointGroupBase
|
|||||||
|
|
||||||
public static async Task<Guid> CreateGoogleUser(ISender sender, CreateGoogleUserCommand command, IUserService userService, IGoogleService googleService)
|
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);
|
return await sender.Send(command);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user