Kétfaktoros első része ok

This commit is contained in:
2025-04-10 20:49:01 +02:00
parent 623a3c49b1
commit d5a7895efa
9 changed files with 284 additions and 15 deletions
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.BL.Services.Interfaces;
@@ -114,6 +114,7 @@ namespace WorkFlowCheck.API.Controllers
}
return retVal;
}
[HttpPost("Authenticate")]
public async Task<ApiResponseDTO<UserDTO>> Authenticate([FromBody] UserSimpleDTO userSimpleDTO)
{
@@ -124,7 +125,7 @@ namespace WorkFlowCheck.API.Controllers
if (string.IsNullOrEmpty(userSimpleDTO.UserName) || string.IsNullOrEmpty(userSimpleDTO.Password))
{
retVal.IsSuccess = false;
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
return retVal;
}
try
@@ -136,11 +137,11 @@ namespace WorkFlowCheck.API.Controllers
{
retVal.IsSuccess = true;
retVal.Data = userDTO_Response;
Log.Information($"Sikeres azonosítás! {userSimpleDTO.UserName}");
Log.Information($"Sikeres azonosítás! {userSimpleDTO.UserName}");
}
else
{
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
retVal.IsSuccess = false;
retVal.Errors.Add(error);
Log.Information(error);
@@ -148,7 +149,49 @@ namespace WorkFlowCheck.API.Controllers
}
else
{
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
retVal.IsSuccess = false;
retVal.Errors.Add(error);
Log.Information(error);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
/// <summary>
/// Ez a 2 faktoros első lépése.
/// </summary>
/// <param name="userSimpleDTO"></param>
/// <returns></returns>
[HttpPost("Authenticate2F1")]
public async Task<ApiResponseDTO<string>> Authenticate2F1([FromBody] UserSimpleDTO userSimpleDTO)
{
var retVal = new ApiResponseDTO<string>()
{
IsSuccess = true
};
if (string.IsNullOrEmpty(userSimpleDTO.UserName) || string.IsNullOrEmpty(userSimpleDTO.Password))
{
retVal.IsSuccess = false;
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
return retVal;
}
try
{
var response = await _userService.Authenticate2F1(userSimpleDTO.UserName, userSimpleDTO.Password);
if (response != null)
{
retVal.IsSuccess = true;
retVal.Data = response;
Log.Information($"Sikeres azonosítás! {userSimpleDTO.UserName}");
}
else
{
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
retVal.IsSuccess = false;
retVal.Errors.Add(error);
Log.Information(error);
@@ -171,7 +214,7 @@ namespace WorkFlowCheck.API.Controllers
if (string.IsNullOrEmpty(userSimpleDTO.UserName) || string.IsNullOrEmpty(userSimpleDTO.Password))
{
retVal.IsSuccess = false;
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
return retVal;
}
try
@@ -183,11 +226,11 @@ namespace WorkFlowCheck.API.Controllers
{
retVal.IsSuccess = true;
retVal.Data = userDTO_Response;
Log.Information($"Sikeres azonosítás! {userSimpleDTO.UserName}");
Log.Information($"Sikeres azonosítás! {userSimpleDTO.UserName}");
}
else
{
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
retVal.IsSuccess = false;
retVal.Errors.Add(error);
Log.Information(error);
@@ -195,7 +238,7 @@ namespace WorkFlowCheck.API.Controllers
}
else
{
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
retVal.IsSuccess = false;
retVal.Errors.Add(error);
Log.Information(error);