...
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
@using Common.Dtos.User
|
||||
@using HushianWebApp.Service
|
||||
@using HushianWebApp.Services
|
||||
@inject UserService userService;
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject AuthService authService;
|
||||
@inject ILocalStorageService localStorageService;
|
||||
<form style="background-color: #ffffff; padding: 20px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); display: flex; flex-direction: column;">
|
||||
|
||||
<label style="margin-bottom: 8px; font-size: 14px; color: #333;" for="oldpass">رمز عبور قبلی:</label>
|
||||
<input dir="ltr" style="text-align:center" @bind="@dto.OldPassword" type="password" class="form-control" placeholder="رمز عبور قبلی" />
|
||||
|
||||
|
||||
<label style="margin-bottom: 8px; font-size: 14px; color: #333; margin-top:15px" for="newpass">رمز عبور جدید:</label>
|
||||
<input dir="ltr" style="text-align:center" @bind="@dto.NewPassword" type="password" class="form-control" placeholder="رمز عبور جدید" />
|
||||
|
||||
<label style="margin-bottom: 8px; font-size: 14px; color: #333; margin-top:15px" for="newpass2">تکرار رمز عبور جدید:</label>
|
||||
<input dir="ltr" style="text-align:center" @bind="RePassword" type="password" class="form-control" placeholder="تکرار رمز عبور جدید" />
|
||||
<ul style="padding-right:10px; padding-top:10px">
|
||||
<li style="color:red">رمز عبور باید حداقل دارای یک کاراکتر باشد</li>
|
||||
<li style="color:red">رمز عبور باید حداقل دارای یک کاراکتر انگلیسی بزرگ باشد</li>
|
||||
<li style="color:red">رمز عبور باید حداقل دارای یک کاراکتر انگلیسی کوچک باشد</li>
|
||||
<li style="color:red">رمز عبور باید حداقل دارای یک عدد باشد</li>
|
||||
</ul>
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<Button style="margin-top:15px" Loading="SpinnerVisible" onclick="@Click" Color="ButtonColor.Primary"> تغییر کلمه عبور </Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@code {
|
||||
[Inject] protected ToastService ToastService { get; set; } = default!;
|
||||
public bool SpinnerVisible { get; set; }
|
||||
public ChangePasswordFromUserDto dto { get; set; } = new();
|
||||
public string RePassword { get; set; } = "";
|
||||
public string Username { get; set; } = "";
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
Username = await localStorageService.GetItem<string>("Username");
|
||||
dto = new() { UserName = Username };
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
async Task Click()
|
||||
{
|
||||
if (string.IsNullOrEmpty(dto.OldPassword) || string.IsNullOrEmpty(dto.NewPassword))
|
||||
return;
|
||||
|
||||
if (dto.NewPassword != RePassword)
|
||||
{
|
||||
ToastService.Notify(new ToastMessage(ToastType.Danger, "کلمه عبور با تکرار متفاوت است"));
|
||||
return;
|
||||
}
|
||||
SpinnerVisible = true;
|
||||
var result = await userService.ChangePasswordYourself(dto);
|
||||
if (result)
|
||||
{
|
||||
ToastService.Notify(new ToastMessage(ToastType.Success, "تغییر کلمه عبور با موفقیت انجام شد"));
|
||||
|
||||
await authService.Logout();
|
||||
NavigationManager.NavigateTo("/login");
|
||||
}
|
||||
else ToastService.Notify(new ToastMessage(ToastType.Danger, "خطا در تغییر کلمه عبور"));
|
||||
|
||||
SpinnerVisible = false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user