2024-05-17 00:32:46 +02:00
|
|
|
|
using System.Net.Http.Headers;
|
|
|
|
|
using Blazored.LocalStorage;
|
|
|
|
|
|
|
|
|
|
namespace TaikoWebUI.Pages.Dialogs;
|
2023-12-19 01:12:48 +01:00
|
|
|
|
|
|
|
|
|
public partial class ResetPasswordConfirmDialog
|
|
|
|
|
{
|
2024-05-01 17:13:47 +02:00
|
|
|
|
[CascadingParameter] private MudDialogInstance MudDialog { get; set; } = null!;
|
2023-12-19 01:12:48 +01:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public User User { get; set; } = new();
|
2024-05-17 00:32:46 +02:00
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
public ILocalStorageService LocalStorage { get; set; } = null!;
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
|
public AuthService AuthService { get; set; } = null!;
|
2023-12-19 01:12:48 +01:00
|
|
|
|
|
|
|
|
|
private void Cancel() => MudDialog.Cancel();
|
2024-03-09 00:42:56 +01:00
|
|
|
|
|
2023-12-19 01:12:48 +01:00
|
|
|
|
private async Task ResetPassword()
|
|
|
|
|
{
|
2024-05-01 17:13:47 +02:00
|
|
|
|
var request = new ResetPasswordRequest
|
2023-12-19 01:12:48 +01:00
|
|
|
|
{
|
2024-05-01 17:13:47 +02:00
|
|
|
|
Baid = User.Baid
|
2023-12-19 01:12:48 +01:00
|
|
|
|
};
|
2024-05-01 17:13:47 +02:00
|
|
|
|
|
|
|
|
|
var responseMessage = await Client.PostAsJsonAsync("api/Auth/ResetPassword", request);
|
2023-12-19 01:12:48 +01:00
|
|
|
|
if (!responseMessage.IsSuccessStatusCode)
|
|
|
|
|
{
|
|
|
|
|
Snackbar.Add("Something went wrong when resetting password!", Severity.Error);
|
|
|
|
|
MudDialog.Close(DialogResult.Ok(false));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-03-09 00:42:56 +01:00
|
|
|
|
|
2023-12-19 01:12:48 +01:00
|
|
|
|
Snackbar.Add("Reset password success!", Severity.Success);
|
|
|
|
|
MudDialog.Close(DialogResult.Ok(true));
|
|
|
|
|
}
|
|
|
|
|
}
|