Browse Source
Merge pull request #17526 from abpframework/Disable-LockoutEnabled-For-Currentuser
Prevent to disable account authenticated user self.
pull/17527/head
liangshiwei
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
19 additions and
8 deletions
-
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs
-
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor
-
modules/identity/src/Volo.Abp.Identity.Blazor/Pages/Identity/UserManagement.razor.cs
-
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml
-
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs
|
|
|
@ -173,7 +173,10 @@ public class IdentityUserAppService : IdentityAppServiceBase, IIdentityUserAppSe |
|
|
|
(await UserManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors(); |
|
|
|
} |
|
|
|
|
|
|
|
(await UserManager.SetLockoutEnabledAsync(user, input.LockoutEnabled)).CheckErrors(); |
|
|
|
if (user.Id != CurrentUser.Id) |
|
|
|
{ |
|
|
|
(await UserManager.SetLockoutEnabledAsync(user, input.LockoutEnabled)).CheckErrors(); |
|
|
|
} |
|
|
|
|
|
|
|
user.Name = input.Name; |
|
|
|
user.Surname = input.Surname; |
|
|
|
|
|
|
|
@ -129,9 +129,12 @@ |
|
|
|
<Field> |
|
|
|
<Check TValue="bool" @bind-Checked="@NewEntity.IsActive">@L["DisplayName:IsActive"]</Check> |
|
|
|
</Field> |
|
|
|
<Field> |
|
|
|
<Check TValue="bool" @bind-Checked="@NewEntity.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Check> |
|
|
|
</Field> |
|
|
|
@if (!IsEditCurrentUser) |
|
|
|
{ |
|
|
|
<Field> |
|
|
|
<Check TValue="bool" @bind-Checked="@NewEntity.LockoutEnabled">@L["DisplayName:LockoutEnabled"]</Check> |
|
|
|
</Field> |
|
|
|
} |
|
|
|
<ExtensionProperties TEntityType="IdentityUserCreateDto" TResourceType="IdentityResource" Entity="@NewEntity" LH="@LH" /> |
|
|
|
</TabPanel> |
|
|
|
<TabPanel Name="Roles"> |
|
|
|
|
|
|
|
@ -41,6 +41,7 @@ public partial class UserManagement |
|
|
|
|
|
|
|
private List<TableColumn> UserManagementTableColumns => TableColumns.Get<UserManagement>(); |
|
|
|
private TextRole _passwordTextRole = TextRole.Password; |
|
|
|
public bool IsEditCurrentUser { get; set; } |
|
|
|
|
|
|
|
public UserManagement() |
|
|
|
{ |
|
|
|
@ -119,7 +120,7 @@ public partial class UserManagement |
|
|
|
try |
|
|
|
{ |
|
|
|
EditModalSelectedTab = DefaultSelectedTab; |
|
|
|
|
|
|
|
IsEditCurrentUser = entity.Id == CurrentUser.Id; |
|
|
|
var userRoleNames = (await AppService.GetRolesAsync(entity.Id)).Items.Select(r => r.Name).ToList(); |
|
|
|
|
|
|
|
EditUserRoles = Roles.Select(x => new AssignedRoleViewModel |
|
|
|
|
|
|
|
@ -39,8 +39,10 @@ |
|
|
|
<abp-input asp-for="UserInfo.Email" /> |
|
|
|
<abp-input asp-for="UserInfo.PhoneNumber" /> |
|
|
|
<abp-input asp-for="UserInfo.IsActive" /> |
|
|
|
<abp-input asp-for="UserInfo.LockoutEnabled" /> |
|
|
|
|
|
|
|
@if (!Model.IsEditCurrentUser) |
|
|
|
{ |
|
|
|
<abp-input asp-for="UserInfo.LockoutEnabled" /> |
|
|
|
} |
|
|
|
@foreach (var propertyInfo in ObjectExtensionManager.Instance.GetProperties<EditModalModel.UserInfoViewModel>()) |
|
|
|
{ |
|
|
|
if (!propertyInfo.Name.EndsWith("_Text")) |
|
|
|
|
|
|
|
@ -22,6 +22,8 @@ public class EditModalModel : IdentityPageModel |
|
|
|
|
|
|
|
protected IIdentityUserAppService IdentityUserAppService { get; } |
|
|
|
|
|
|
|
public bool IsEditCurrentUser { get; set; } |
|
|
|
|
|
|
|
public EditModalModel(IIdentityUserAppService identityUserAppService) |
|
|
|
{ |
|
|
|
IdentityUserAppService = identityUserAppService; |
|
|
|
@ -30,7 +32,7 @@ public class EditModalModel : IdentityPageModel |
|
|
|
public virtual async Task<IActionResult> OnGetAsync(Guid id) |
|
|
|
{ |
|
|
|
UserInfo = ObjectMapper.Map<IdentityUserDto, UserInfoViewModel>(await IdentityUserAppService.GetAsync(id)); |
|
|
|
|
|
|
|
IsEditCurrentUser = CurrentUser.Id == id; |
|
|
|
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>((await IdentityUserAppService.GetAssignableRolesAsync()).Items); |
|
|
|
|
|
|
|
var userRoleNames = (await IdentityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList(); |
|
|
|
|