Prevent user from changing their password
This commit is contained in:
@ -19,7 +19,7 @@
|
|||||||
<RadzenStack Gap="1rem" class="rz-p-sm-4">
|
<RadzenStack Gap="1rem" class="rz-p-sm-4">
|
||||||
<RadzenFormField Text="Роль" Variant="Variant.Outlined">
|
<RadzenFormField Text="Роль" Variant="Variant.Outlined">
|
||||||
<ChildContent>
|
<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>
|
</ChildContent>
|
||||||
</RadzenFormField>
|
</RadzenFormField>
|
||||||
<RadzenFormField Text="Новый пароль" Variant="Variant.Outlined">
|
<RadzenFormField Text="Новый пароль" Variant="Variant.Outlined">
|
||||||
@ -54,6 +54,8 @@
|
|||||||
@code {
|
@code {
|
||||||
sealed class InputModel
|
sealed class InputModel
|
||||||
{
|
{
|
||||||
|
public bool RoleDisabled { get; set; }
|
||||||
|
|
||||||
public string RoleId { get; set; }
|
public string RoleId { get; set; }
|
||||||
|
|
||||||
public string Password { get; set; } = "";
|
public string Password { get; set; } = "";
|
||||||
@ -67,10 +69,13 @@
|
|||||||
string errorMessage;
|
string errorMessage;
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string UserId { get; set; }
|
public required string CurrentUserId { get; set; }
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string RoleId { get; set; }
|
public required string UserId { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public required string RoleId { get; set; }
|
||||||
|
|
||||||
[SupplyParameterFromForm]
|
[SupplyParameterFromForm]
|
||||||
InputModel Input { get; set; } = new();
|
InputModel Input { get; set; } = new();
|
||||||
@ -79,9 +84,10 @@
|
|||||||
{
|
{
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
|
|
||||||
roles = await RoleManager.Roles.OrderBy(x => x.Priority).ToListAsync();
|
Input.RoleDisabled = CurrentUserId == UserId;
|
||||||
|
|
||||||
Input.RoleId = RoleId;
|
Input.RoleId = RoleId;
|
||||||
|
|
||||||
|
roles = await RoleManager.Roles.OrderBy(x => x.Priority).ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task DoEditUser(InputModel input)
|
async Task DoEditUser(InputModel input)
|
||||||
|
|||||||
@ -108,6 +108,7 @@
|
|||||||
"Редактирование пользователя",
|
"Редактирование пользователя",
|
||||||
new Dictionary<string, object>()
|
new Dictionary<string, object>()
|
||||||
{
|
{
|
||||||
|
{ nameof(Dialogs.EditUser.CurrentUserId), currentUserId },
|
||||||
{ nameof(Dialogs.EditUser.UserId), userWithRole.User.Id },
|
{ nameof(Dialogs.EditUser.UserId), userWithRole.User.Id },
|
||||||
{ nameof(Dialogs.EditUser.RoleId), userWithRole.Role.Id }
|
{ nameof(Dialogs.EditUser.RoleId), userWithRole.Role.Id }
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user