- Create RolePermissionService (delegates to AppPermissions) - Create AuthSignInService (wraps SignInManager) - Create AuthDataService (handles settings, first-user, token revocation) - Register all new services in Infrastructure DI - Fix AuthDataService RevokedRefreshToken constructor usage - All 226 tests passing
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
using Heimdall.Application.Services;
|
|
using Heimdall.Domain.Entities;
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
namespace Heimdall.Infrastructure.Security;
|
|
|
|
public class AuthSignInService : IAuthSignInService
|
|
{
|
|
private readonly SignInManager<AppUser> _signInManager;
|
|
|
|
public AuthSignInService(SignInManager<AppUser> signInManager)
|
|
{
|
|
_signInManager = signInManager;
|
|
}
|
|
|
|
public async Task<SignInServiceResult> PasswordSignInAsync(AppUser user, string password, bool lockoutOnFailure)
|
|
{
|
|
var result = await _signInManager.PasswordSignInAsync(user, password, false, lockoutOnFailure);
|
|
return result switch
|
|
{
|
|
{ Succeeded: true } => new SignInServiceResult(SignInResultType.Success),
|
|
{ IsLockedOut: true } => new SignInServiceResult(SignInResultType.LockedOut),
|
|
{ RequiresTwoFactor: true } => new SignInServiceResult(SignInResultType.RequiresTwoFactor),
|
|
_ => new SignInServiceResult(SignInResultType.Failed)
|
|
};
|
|
}
|
|
|
|
public async Task SignOutAsync()
|
|
{
|
|
await _signInManager.SignOutAsync();
|
|
}
|
|
}
|