Test: Google oauth
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Google.Apis.Oauth2.v2.Data;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Application.Common.Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -30,6 +31,23 @@ public class IdentityService(
|
||||
|
||||
return (result.ToApplicationResult(), user.Id);
|
||||
}
|
||||
|
||||
public async Task<(Result Result, string UserId)> CreateUserAsync(Userinfo userInfo)
|
||||
{
|
||||
var user = new ApplicationUser
|
||||
{
|
||||
UserName = userInfo.Name,
|
||||
Email = userInfo.Email,
|
||||
FirstName = userInfo.GivenName,
|
||||
LastName = userInfo.FamilyName
|
||||
};
|
||||
|
||||
var password = Guid.NewGuid().ToString("N")[..32];
|
||||
|
||||
var result = await userManager.CreateAsync(user, password);
|
||||
|
||||
return (result.ToApplicationResult(), user.Id);
|
||||
}
|
||||
|
||||
public async Task<bool> IsInRoleAsync(string userId, string role)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user