Patch JWT v2
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 4m57s

This commit is contained in:
Leandro Hernan Rojas 2025-04-28 19:49:56 -03:00
parent 4c6c7ab548
commit 5e7c71874a

View File

@ -91,8 +91,32 @@ else
{ {
await RefreshAll(); await RefreshAll();
} }
// public async Task RefreshAll()
// {
// var response = await _httpClient.GetAsync("/api/Account/GetAllUsers");
// if (response.IsSuccessStatusCode)
// {
// var jsonResponse = await response.Content.ReadAsStringAsync();
// var options = new JsonSerializerOptions
// {
// PropertyNameCaseInsensitive = true
// };
// var deserializedUsers = JsonSerializer.Deserialize<List<User>>(jsonResponse, options);
// users = deserializedUsers ?? new List<User>();
// StateHasChanged();
// }
// }
public async Task RefreshAll() public async Task RefreshAll()
{ {
var customAuthStateProvider = (CustomAuthorizationProvider)authenticationStateProvider;
var token = await customAuthStateProvider.GetTokenData();
if (!string.IsNullOrWhiteSpace(token.token))
{
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.token);
}
var response = await _httpClient.GetAsync("/api/Account/GetAllUsers"); var response = await _httpClient.GetAsync("/api/Account/GetAllUsers");
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
@ -108,17 +132,26 @@ else
StateHasChanged(); StateHasChanged();
} }
} }
public void EditUser(string userId) public void EditUser(string userId)
{ {
navigation.NavigateTo($"/userform/edit/{userId}"); navigation.NavigateTo($"/userform/edit/{userId}");
} }
public async Task RecoveryPassword(string email) public async Task RecoveryPassword(string email)
{ {
var customAuthStateProvider = (CustomAuthorizationProvider)authenticationStateProvider;
var token = await customAuthStateProvider.GetTokenData();
if (!string.IsNullOrWhiteSpace(token.token))
{
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.token);
}
string url = $"api/Authentication/forgot-password?email={email}"; string url = $"api/Authentication/forgot-password?email={email}";
var response = await _httpClient.PostAsync(url,null); var response = await _httpClient.PostAsync(url, null);
var message = await response.Content.ReadAsStringAsync(); var message = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
toastService.ShowSuccess(message); toastService.ShowSuccess(message);
@ -126,8 +159,23 @@ else
else else
{ {
toastService.ShowError(message); toastService.ShowError(message);
}; }
} }
// public async Task RecoveryPassword(string email)
// {
// string url = $"api/Authentication/forgot-password?email={email}";
// var response = await _httpClient.PostAsync(url,null);
// var message = await response.Content.ReadAsStringAsync();
// if (response.IsSuccessStatusCode)
// {
// toastService.ShowSuccess(message);
// }
// else
// {
// toastService.ShowError(message);
// };
// }
private void ConfirmDelete(string userId) private void ConfirmDelete(string userId)
{ {
var parameters = new ModalParameters() var parameters = new ModalParameters()