Na most van kész a 2 faktoros authentikáció ! :)
This commit is contained in:
@@ -8,6 +8,8 @@ namespace WorkFlowCheck.Web.Services.Interfaces
|
||||
Task<List<UserDTO>> GetAllUsers();
|
||||
Task<ApiResponseDTO<UserDTO>> UpdateUser(UserDTO userDTO);
|
||||
Task<ApiResponseDTO<UserDTO>> Authenticate(string username, string password);
|
||||
Task<ApiResponseDTO<string>> Authenticate2F1(string username, string password);
|
||||
Task<ApiResponseDTO<UserDTO>> Authenticate2F2(string userName, string password, string code, string token2FA);
|
||||
Task<bool> DeleteUser(int id);
|
||||
|
||||
Task<RoleDTO> GetRole(int id);
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace WorkFlowCheck.Web.Services
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<ApiResponseDTO<UserDTO>> UpdateUser(UserDTO userDTO)
|
||||
public async Task<ApiResponseDTO<UserDTO>> UpdateUser(UserDTO userDTO)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -94,9 +94,9 @@ namespace WorkFlowCheck.Web.Services
|
||||
{
|
||||
UserName = username,
|
||||
Password = password,
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, userSimpleDTO))
|
||||
{
|
||||
@@ -120,6 +120,81 @@ namespace WorkFlowCheck.Web.Services
|
||||
};
|
||||
}
|
||||
}
|
||||
public async Task<ApiResponseDTO<string>> Authenticate2F1(string username, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Az API végpont meghatározása
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/User/Authenticate2F1";
|
||||
|
||||
var userSimpleDTO = new UserSimpleDTO()
|
||||
{
|
||||
UserName = username,
|
||||
Password = password,
|
||||
|
||||
};
|
||||
|
||||
|
||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, userSimpleDTO))
|
||||
{
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
var response = JsonConvert.DeserializeObject<ApiResponseDTO<string>>(jsonString);
|
||||
|
||||
return response ?? new ApiResponseDTO<string>
|
||||
{
|
||||
IsSuccess = false,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Hiba visszaadása
|
||||
return new ApiResponseDTO<string>
|
||||
{
|
||||
IsSuccess = false
|
||||
};
|
||||
}
|
||||
}
|
||||
public async Task<ApiResponseDTO<UserDTO>> Authenticate2F2(string userName, string password, string code, string token2FA)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/User/Authenticate2F2";
|
||||
|
||||
var userSimpleDTO = new User2FADTO()
|
||||
{
|
||||
UserName = userName,
|
||||
Password = password,
|
||||
Code = code,
|
||||
Token2FA = token2FA
|
||||
};
|
||||
|
||||
|
||||
using (HttpResponseMessage httpResponseMessage = await _httpClient.PostAsJsonAsync(endpoint, userSimpleDTO))
|
||||
{
|
||||
httpResponseMessage.EnsureSuccessStatusCode();
|
||||
|
||||
var jsonString = await httpResponseMessage.Content.ReadAsStringAsync();
|
||||
var response = JsonConvert.DeserializeObject<ApiResponseDTO<UserDTO>>(jsonString);
|
||||
|
||||
return response ?? new ApiResponseDTO<UserDTO>
|
||||
{
|
||||
IsSuccess = false,
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return new ApiResponseDTO<UserDTO>
|
||||
{
|
||||
IsSuccess = false
|
||||
};
|
||||
}
|
||||
}
|
||||
public async Task<bool> DeleteUser(int id)
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/User/DeleteUser/{id}";
|
||||
@@ -326,7 +401,7 @@ namespace WorkFlowCheck.Web.Services
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<RoleCheckListTemplateHeaderDTO>> GetAllRoleCheckListTemplates()
|
||||
public async Task<List<RoleCheckListTemplateHeaderDTO>> GetAllRoleCheckListTemplates()
|
||||
{
|
||||
string endpoint = $"{_httpClient.BaseAddress}api/User/GetAllRoleCheckListTemplateHeaders";
|
||||
var retVal = new List<RoleCheckListTemplateHeaderDTO>();
|
||||
@@ -446,5 +521,7 @@ namespace WorkFlowCheck.Web.Services
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user