Prevent user from changing their password

This commit is contained in:
2025-10-20 17:14:13 +09:00
parent d7d1b09837
commit dad0a9009e
2 changed files with 12 additions and 5 deletions

View File

@ -19,7 +19,7 @@
<RadzenStack Gap="1rem" class="rz-p-sm-4">
<RadzenFormField Text="Роль" Variant="Variant.Outlined">
<ChildContent>
<RadzenDropDown Data="@roles" TextProperty="Name" ValueProperty="Id" @bind-Value="@Input.RoleId" Name="Role" style="width: 100%" />
<RadzenDropDown Data="@roles" TextProperty="Name" ValueProperty="Id" @bind-Value="@Input.RoleId" Disabled="@Input.RoleDisabled" Name="Role" style="width: 100%" />
</ChildContent>
</RadzenFormField>
<RadzenFormField Text="Новый пароль" Variant="Variant.Outlined">
@ -54,6 +54,8 @@
@code {
sealed class InputModel
{
public bool RoleDisabled { get; set; }
public string RoleId { get; set; }
public string Password { get; set; } = "";
@ -67,10 +69,13 @@
string errorMessage;
[Parameter]
public string UserId { get; set; }
public required string CurrentUserId { get; set; }
[Parameter]
public string RoleId { get; set; }
public required string UserId { get; set; }
[Parameter]
public required string RoleId { get; set; }
[SupplyParameterFromForm]
InputModel Input { get; set; } = new();
@ -79,9 +84,10 @@
{
await base.OnInitializedAsync();
roles = await RoleManager.Roles.OrderBy(x => x.Priority).ToListAsync();
Input.RoleDisabled = CurrentUserId == UserId;
Input.RoleId = RoleId;
roles = await RoleManager.Roles.OrderBy(x => x.Priority).ToListAsync();
}
async Task DoEditUser(InputModel input)

View File

@ -108,6 +108,7 @@
"Редактирование пользователя",
new Dictionary<string, object>()
{
{ nameof(Dialogs.EditUser.CurrentUserId), currentUserId },
{ nameof(Dialogs.EditUser.UserId), userWithRole.User.Id },
{ nameof(Dialogs.EditUser.RoleId), userWithRole.Role.Id }
},