feat: add admin password change form
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
@page "/admin/settings"
|
@page "/admin/settings"
|
||||||
|
@using System.ComponentModel.DataAnnotations
|
||||||
|
@using TaxBaik.Web.Services
|
||||||
@using TaxBaik.Domain.Interfaces
|
@using TaxBaik.Domain.Interfaces
|
||||||
|
@inject IApiClient ApiClient
|
||||||
@inject ISnackbar Snackbar
|
@inject ISnackbar Snackbar
|
||||||
|
|
||||||
<PageTitle>설정</PageTitle>
|
<PageTitle>설정</PageTitle>
|
||||||
@@ -25,11 +28,36 @@
|
|||||||
</MudForm>
|
</MudForm>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
|
|
||||||
|
<MudPaper Class="pa-4 mt-4" Elevation="1">
|
||||||
|
<MudText Typo="Typo.h6" Class="mb-4">계정 관리</MudText>
|
||||||
|
|
||||||
|
<MudForm>
|
||||||
|
<MudTextField @bind-Value="currentPassword" Label="현재 비밀번호" InputType="InputType.Password"
|
||||||
|
Variant="Variant.Outlined" Class="mb-4" />
|
||||||
|
|
||||||
|
<MudTextField @bind-Value="newPassword" Label="새 비밀번호" InputType="InputType.Password"
|
||||||
|
Variant="Variant.Outlined" Class="mb-4" />
|
||||||
|
|
||||||
|
<MudTextField @bind-Value="confirmNewPassword" Label="새 비밀번호 확인" InputType="InputType.Password"
|
||||||
|
Variant="Variant.Outlined" Class="mb-4" />
|
||||||
|
|
||||||
|
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
||||||
|
Disabled="@isChangingPassword"
|
||||||
|
@onclick="ChangePassword">
|
||||||
|
@(isChangingPassword ? "변경 중..." : "비밀번호 변경")
|
||||||
|
</MudButton>
|
||||||
|
</MudForm>
|
||||||
|
</MudPaper>
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
private string phone = "010-4122-8268";
|
private string phone = "010-4122-8268";
|
||||||
private string email = "taxbaik5668@gmail.com";
|
private string email = "taxbaik5668@gmail.com";
|
||||||
private string kakaoUrl = "http://pf.kakao.com/_xoxchTX";
|
private string kakaoUrl = "http://pf.kakao.com/_xoxchTX";
|
||||||
private string instagramUrl = "https://www.instagram.com/taxtory5668/";
|
private string instagramUrl = "https://www.instagram.com/taxtory5668/";
|
||||||
|
private string currentPassword = "";
|
||||||
|
private string newPassword = "";
|
||||||
|
private string confirmNewPassword = "";
|
||||||
|
private bool isChangingPassword;
|
||||||
|
|
||||||
private async Task SaveSettings()
|
private async Task SaveSettings()
|
||||||
{
|
{
|
||||||
@@ -37,4 +65,57 @@
|
|||||||
Snackbar.Add("설정 저장 기능은 아직 구현되지 않았습니다.", Severity.Info);
|
Snackbar.Add("설정 저장 기능은 아직 구현되지 않았습니다.", Severity.Info);
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task ChangePassword()
|
||||||
|
{
|
||||||
|
if (isChangingPassword)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(currentPassword) || string.IsNullOrWhiteSpace(newPassword))
|
||||||
|
{
|
||||||
|
Snackbar.Add("현재 비밀번호와 새 비밀번호를 입력하세요.", Severity.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newPassword != confirmNewPassword)
|
||||||
|
{
|
||||||
|
Snackbar.Add("새 비밀번호 확인이 일치하지 않습니다.", Severity.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isChangingPassword = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = await ApiClient.PostAsync<ChangePasswordResponse>("auth/change-password", new
|
||||||
|
{
|
||||||
|
CurrentPassword = currentPassword,
|
||||||
|
NewPassword = newPassword
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response?.Message == null)
|
||||||
|
{
|
||||||
|
Snackbar.Add("비밀번호 변경에 실패했습니다.", Severity.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Snackbar.Add(response.Message, Severity.Success);
|
||||||
|
currentPassword = "";
|
||||||
|
newPassword = "";
|
||||||
|
confirmNewPassword = "";
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Snackbar.Add("비밀번호 변경 중 오류가 발생했습니다.", Severity.Error);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
isChangingPassword = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ChangePasswordResponse
|
||||||
|
{
|
||||||
|
public string Message { get; set; } = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user