Add GetCreatorByAlias and CreatorAlias to User

This commit is contained in:
Jonathan Bourdon
2024-07-02 03:11:06 -04:00
parent bc2dc969ff
commit eb2136083b
13 changed files with 737 additions and 20 deletions

View 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;
}
}