Add GetCreatorByAlias and CreatorAlias to User
This commit is contained in:
42
src/Infrastructure/Identity/ApplicationUserManager.cs
Normal file
42
src/Infrastructure/Identity/ApplicationUserManager.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Hutopy.Infrastructure.Identity;
|
||||
|
||||
public sealed class ApplicationUserManager(
|
||||
IUserStore<ApplicationUser> store,
|
||||
IOptions<IdentityOptions> optionsAccessor,
|
||||
IPasswordHasher<ApplicationUser> passwordHasher,
|
||||
IEnumerable<IUserValidator<ApplicationUser>> userValidators,
|
||||
IEnumerable<IPasswordValidator<ApplicationUser>> passwordValidators,
|
||||
ILookupNormalizer keyNormalizer,
|
||||
IdentityErrorDescriber errors,
|
||||
IServiceProvider services,
|
||||
ILogger<UserManager<ApplicationUser>> logger)
|
||||
: UserManager<ApplicationUser>(
|
||||
store,
|
||||
optionsAccessor,
|
||||
passwordHasher,
|
||||
userValidators,
|
||||
passwordValidators,
|
||||
keyNormalizer,
|
||||
errors,
|
||||
services,
|
||||
logger)
|
||||
{
|
||||
public async Task<ApplicationUser?> FindByCreatorAliasAsync(string creatorAlias,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrEmpty(creatorAlias);
|
||||
ThrowIfDisposed();
|
||||
|
||||
var user = await Users.SingleOrDefaultAsync(u => EF.Functions.Like(
|
||||
creatorAlias,
|
||||
u.CreatorAlias),
|
||||
cancellationToken: cancellationToken);
|
||||
|
||||
return user;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user