Create minimal app

This commit is contained in:
danial23 2025-05-20 03:05:37 -04:00
parent 6b87902ca7
commit 27aaee6293
Signed by: danial23
SSH key fingerprint: SHA256:IJ8VP0j2WMUVweTYnzUUnEjNgPnGx+mAt+RhqWZ01bU
17 changed files with 346 additions and 52 deletions

View file

@ -10,4 +10,8 @@ public interface IUserService
string email,
string password
);
record LoginResult(Domain.Entities.User? User, string? Error);
Task<LoginResult> Login(string username, string password);
}

View file

@ -50,4 +50,20 @@ public class UserService(IUserRepository userRepository, Domain.Interfaces.IPass
return new IUserService.RegisterNewUserResult(user, null);
}
public async Task<IUserService.LoginResult> Login(string username, string password)
{
var user = await _userRepository.GetByUsernameAsync(username);
if (user == null)
{
return new IUserService.LoginResult(null, "User not found.");
}
if (!user.VerifyPassword(password, _passwordHasher))
{
return new IUserService.LoginResult(null, "Wrong password.");
}
return new IUserService.LoginResult(user, null);
}
}