Egy kis authentikáció

This commit is contained in:
2025-01-21 15:52:30 +01:00
parent 3b11c6adc5
commit 30d82fc9bf
12 changed files with 186 additions and 12 deletions
+21 -1
View File
@@ -6,9 +6,10 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WorkFlowCheck.BL.DTO;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.BL.Services.Interfaces;
using WorkFlowCheck.DL;
using WorkFlowCheck.Common.Security;
namespace WorkFlowCheck.BL.Services
{
@@ -39,5 +40,24 @@ namespace WorkFlowCheck.BL.Services
}
return retVal;
}
public async Task<UserDTO> Authenticate(string userName, string password)
{
var retVal = new UserDTO();
try
{
var user = await _dbContext.Users.Where(w => w.UserName == userName).FirstOrDefaultAsync();
if (user != null && PasswordHasher.VerifyPassword(user.PasswordHash, password))
{
retVal = _mapper.Map<UserDTO>(user);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
}
}