1
0
mirror of synced 2024-11-28 00:20:53 +01:00
TaikoLocalServer/TaikoWebUI/Pages/ChangePassword.razor.cs

82 lines
3.0 KiB
C#
Raw Normal View History

2023-10-16 11:38:27 +02:00
namespace TaikoWebUI.Pages;
public partial class ChangePassword
{
private string cardNum = "";
private MudForm changePasswordForm = default!;
private string confirmNewPassword = "";
private string newPassword = "";
private string oldPassword = "";
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (AuthService.LoginRequired && !AuthService.IsLoggedIn)
{
await AuthService.LoginWithAuthToken();
}
2024-08-13 17:07:39 +02:00
BreadcrumbsStateContainer.breadcrumbs.Clear();
BreadcrumbsStateContainer.breadcrumbs.Add(new BreadcrumbItem(Localizer["Change Password"], href: "/"));
BreadcrumbsStateContainer.NotifyStateChanged();
2023-10-16 11:38:27 +02:00
}
private async Task OnChangePassword()
{
2024-05-17 00:32:46 +02:00
var result = await AuthService.ChangePassword(cardNum, oldPassword, newPassword, confirmNewPassword);
switch (result)
2023-10-16 11:38:27 +02:00
{
2024-05-17 00:32:46 +02:00
case 0:
await DialogService.ShowMessageBox(
Localizer["Error"],
2024-06-05 03:07:33 +02:00
(MarkupString)
(string)Localizer["Login Only Admin Error"],
2024-05-17 00:32:46 +02:00
Localizer["Dialog OK"]);
NavigationManager.NavigateTo("/Users");
break;
case 1:
await DialogService.ShowMessageBox(
Localizer["Success"],
2024-06-05 03:07:33 +02:00
(MarkupString)
(string)Localizer["Change Password Success"],
2024-05-17 00:32:46 +02:00
Localizer["Dialog OK"]);
NavigationManager.NavigateTo("/Users");
break;
case 2:
await DialogService.ShowMessageBox(
Localizer["Error"],
2024-06-05 03:07:33 +02:00
(MarkupString)
(string)Localizer["Change Password Different Confirm Password Error"],
2024-05-17 00:32:46 +02:00
Localizer["Dialog OK"]);
break;
case 3:
await DialogService.ShowMessageBox(
Localizer["Error"],
(MarkupString)
2024-06-05 03:07:33 +02:00
(string)Localizer["Unknown Access Code Error"],
2024-05-17 00:32:46 +02:00
Localizer["Dialog OK"]);
break;
case 4:
await DialogService.ShowMessageBox(
Localizer["Error"],
(MarkupString)
2024-06-05 03:07:33 +02:00
(string)Localizer["Change Password Wrong Current Password Error"],
2024-05-17 00:32:46 +02:00
Localizer["Dialog OK"]);
break;
case 5:
await DialogService.ShowMessageBox(
Localizer["Error"],
(MarkupString)
2024-06-05 03:07:33 +02:00
(string)Localizer["Access Code Not Registered Error"],
2024-05-17 00:32:46 +02:00
Localizer["Dialog OK"]);
break;
case 6:
await DialogService.ShowMessageBox(
Localizer["Error"],
Localizer["Unknown Error"],
Localizer["Dialog OK"]);
break;
2023-10-16 11:38:27 +02:00
}
}
}