auth clean up

This commit is contained in:
Kalana B. Thilakarathna
2026-08-25 16:11:37 +05:30
parent 916a2b8f0a
commit bb33928661
9 changed files with 2724 additions and 51 deletions
+4 -22
View File
@@ -1,24 +1,6 @@
using Distribution.Features.User;
using Distribution.Infra.Authorization;
using Microsoft.AspNetCore.Identity;
namespace Distribution.Features.Auth;
public class AuthService(IUserRepository userRepo, IJwtTokenService tokenService)
{
private readonly PasswordHasher<Models.User> _hasher = new();
public async Task<LoginResponse?> LoginAsync(LoginRequest request)
{
var user = await userRepo.GetByUsernameAsync(request.Username);
if (user is null || !user.IsActive)
return null;
var result = _hasher.VerifyHashedPassword(user, user.PasswordHash, request.Password);
if (result == PasswordVerificationResult.Failed)
return null;
var token = tokenService.GenerateToken(user);
return new LoginResponse(token, user.Id, user.Username, user.Role?.Name ?? string.Empty);
}
}
// TODO: This service previously contained local password validation logic.
// It has been replaced by the IAuthServiceClient connector which proxies
// to the external Auth Service. Remove this file or repurpose it for any
// local orchestration logic once the Auth Service contract is defined.