Files
social-media/src/Infrastructure/Identity/ApplicationUserManager.cs
Dominic Villemure 4a0502488e Merged with master
2024-07-04 20:50:20 -04:00

47 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
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;
}
}