25 lines
639 B
C#
25 lines
639 B
C#
using AuthApp.Data;
|
|
using AuthApp.Utils;
|
|
|
|
/// <summary>
|
|
/// Сервис аутентификации
|
|
/// </summary>
|
|
namespace AuthApp.Services
|
|
{
|
|
public class AuthService
|
|
{
|
|
private readonly UserRepository _repository = new();
|
|
|
|
/// <summary>
|
|
/// Проверка логина и пароля
|
|
/// </summary>
|
|
public bool Authenticate(string login, string password)
|
|
{
|
|
var user = _repository.GetUser(login);
|
|
if (user == null) return false;
|
|
|
|
string hash = PasswordHasher.Hash(password);
|
|
return (user.PasswordHash == hash);
|
|
}
|
|
}
|
|
}
|