35 lines
1021 B
C#
35 lines
1021 B
C#
using NetworkResurrector.Domain.Entities;
|
|
using NetworkResurrector.Domain.Services;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace NetworkResurrector.Application.Services
|
|
{
|
|
public interface IUserService
|
|
{
|
|
Task<User> Authenticate(string username, string password);
|
|
}
|
|
|
|
public class UserService : IUserService
|
|
{
|
|
private readonly IParamProvider _paramProvider;
|
|
|
|
public UserService(IParamProvider paramProvider)
|
|
{
|
|
_paramProvider = paramProvider;
|
|
}
|
|
|
|
public async Task<User> Authenticate(string username, string password)
|
|
{
|
|
return await Task.Run(() => CheckCredentials(username, password));
|
|
}
|
|
|
|
private User CheckCredentials(string username, string password)
|
|
{
|
|
if (_paramProvider.Credentials.UserName == username && _paramProvider.Credentials.Password == password)
|
|
return new User() { UserName = username, Id = 1 };
|
|
else
|
|
return null;
|
|
}
|
|
}
|
|
}
|