User továbbgondolása

This commit is contained in:
2025-03-17 12:10:41 +01:00
parent 0e06382eee
commit 8c1e60889d
11 changed files with 306 additions and 44 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;
@@ -49,8 +49,8 @@ namespace WorkFlowCheck.API.Controllers
return retVal;
}
[HttpGet("GetAllUser")]
public async Task<ApiResponseDTO<List<UserDTO>>> GetAllUser()
[HttpGet("GetAllUsers")]
public async Task<ApiResponseDTO<List<UserDTO>>> GetAllUsers()
{
var retVal = new ApiResponseDTO<List<UserDTO>>()
{
@@ -93,32 +93,32 @@ namespace WorkFlowCheck.API.Controllers
return retVal;
}
[HttpPost("Authenticate")]
public async Task<ApiResponseDTO<UserDTO>> Authenticate([FromBody] UserDTO userDTO)
public async Task<ApiResponseDTO<UserDTO>> Authenticate([FromBody] UserDTO userSimpleDTO)
{
var retVal = new ApiResponseDTO<UserDTO>()
{
IsSuccess = true
};
if (string.IsNullOrEmpty(userDTO.UserName) || string.IsNullOrEmpty(userDTO.Password))
if (string.IsNullOrEmpty(userSimpleDTO.UserName) || string.IsNullOrEmpty(userSimpleDTO.Password))
{
retVal.IsSuccess = false;
retVal.Errors.Add("Nem megfelelő felhasználói név vagy jelszó");
retVal.Errors.Add("Nem megfelelo felhasználói név vagy jelszó");
return retVal;
}
try
{
var userDTO_Response = await _userService.Authenticate(userDTO.UserName, userDTO.Password);
var userDTO_Response = await _userService.Authenticate(userSimpleDTO.UserName, userSimpleDTO.Password);
if (userDTO_Response != null)
{
if (string.IsNullOrEmpty(userDTO_Response.UserName) == false && userDTO_Response.UserName == userDTO.UserName)
if (string.IsNullOrEmpty(userDTO_Response.UserName) == false && userDTO_Response.UserName == userSimpleDTO.UserName)
{
retVal.IsSuccess = true;
retVal.Data = userDTO_Response;
Log.Information($"Sikeres azonosítás! {userDTO.UserName}");
Log.Information($"Sikeres azonosítás! {userSimpleDTO.UserName}");
}
else
{
var error = $"Nem megfelelő felhasználó vagy jelszó! {userDTO.UserName}";
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
retVal.IsSuccess = false;
retVal.Errors.Add(error);
Log.Information(error);
@@ -126,7 +126,7 @@ namespace WorkFlowCheck.API.Controllers
}
else
{
var error = $"Nem megfelelő felhasználó vagy jelszó! {userDTO.UserName}";
var error = $"Nem megfelelo felhasználó vagy jelszó! {userSimpleDTO.UserName}";
retVal.IsSuccess = false;
retVal.Errors.Add(error);
Log.Information(error);
@@ -171,8 +171,8 @@ namespace WorkFlowCheck.API.Controllers
return retVal;
}
[HttpGet("GetAllRole")]
public async Task<ApiResponseDTO<List<RoleDTO>>> GetAllRole()
[HttpGet("GetAllRoles")]
public async Task<ApiResponseDTO<List<RoleDTO>>> GetAllRoles()
{
var retVal = new ApiResponseDTO<List<RoleDTO>>()
{