Add GetCreatorByAlias and CreatorAlias to User
This commit is contained in:
@@ -16,7 +16,7 @@ using Microsoft.Extensions.Configuration;
|
||||
namespace Hutopy.Infrastructure.Identity;
|
||||
|
||||
public class IdentityService(
|
||||
UserManager<ApplicationUser> userManager,
|
||||
ApplicationUserManager userManager,
|
||||
SignInManager<ApplicationUser> signInManager,
|
||||
IUserClaimsPrincipalFactory<ApplicationUser> userClaimsPrincipalFactory,
|
||||
IAuthorizationService authorizationService,
|
||||
@@ -135,10 +135,28 @@ public class IdentityService(
|
||||
|
||||
public async Task<UserModel?> FindUserByIdAsync(string id)
|
||||
{
|
||||
var response = await userManager.FindByIdAsync(id);
|
||||
var user = await userManager.FindByIdAsync(id);
|
||||
|
||||
if (response == null) return null;
|
||||
if (user == null) return null;
|
||||
|
||||
var userModel = BuildModelFrom(user);
|
||||
|
||||
return userModel;
|
||||
}
|
||||
|
||||
public async Task<UserModel?> FindUserByCreatorAliasAsync(string creatorAlias, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var user = await userManager.FindByCreatorAliasAsync(creatorAlias, cancellationToken);
|
||||
|
||||
if (user == null) return null;
|
||||
|
||||
var userModel = BuildModelFrom(user);
|
||||
|
||||
return userModel;
|
||||
}
|
||||
|
||||
private static UserModel BuildModelFrom(ApplicationUser response)
|
||||
{
|
||||
var userModel = new UserModel
|
||||
{
|
||||
Id = response.Id,
|
||||
@@ -179,10 +197,9 @@ public class IdentityService(
|
||||
WebsiteIconUrl = response.StoredDataUrls.WebsiteIconUrl,
|
||||
}
|
||||
};
|
||||
|
||||
return userModel;
|
||||
}
|
||||
|
||||
|
||||
public async Task<UserModel?> FindUserByEmailAsync(string email)
|
||||
{
|
||||
var response = await userManager.FindByEmailAsync(email);
|
||||
|
||||
Reference in New Issue
Block a user