network-resurrector/NetworkResurrector.Application/Services/UserService.cs

35 lines
1021 B
C#
Raw Normal View History

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;
}
}
}