You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.2 KiB

using Easy;
using Easy.DDD.Domain;
using Easy.DDD.Domain.Repositories;
3 years ago
using Identity.Api.Clean.Domain.Entites;
using Identity.Api.Clean.Shared.Consts;
using Identity.Api.Clean.Shared.IServices;
3 years ago
namespace Identity.Api.Clean.Domain.Services;
3 years ago
public class IdentityUserManager : DomainService, IIdentityUserManager
{
3 years ago
protected IPermissionGrantManager PermissionGrantManager => LazyServiceProvider.LazyGetService<IPermissionGrantManager>();
protected IRepository<IdentityUser> IdentityUserRepository { get; }
3 years ago
public IdentityUserManager(IRepository<IdentityUser> identityUserRepository)
{
IdentityUserRepository = identityUserRepository;
}
public async Task<IdentityUser> PasswordSignInAsync(string accout, string passwordHash)
{
When.Is(string.IsNullOrEmpty(accout), LoginResultConst.UserNameNotNullError);
When.Is(string.IsNullOrEmpty(passwordHash), LoginResultConst.PassWordNotNullError);
var identityUser = await IdentityUserRepository
.FirstOrDefaultAsync(o => o.UserAccount == accout && o.PasswordHash == passwordHash);
When.Is(identityUser == null, LoginResultConst.PassWordLoginError);
return identityUser;
}
}