Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Commit

Permalink
Rework admin multitenancy role #14
Browse files Browse the repository at this point in the history
change after CR
  • Loading branch information
plakhov committed Jul 21, 2021
1 parent 15faa17 commit 0d45c27
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ system entities.

**Note**. The role does not allow manage users if you want you should create a role that allows that. For example
```java
@ResourceRole(name = "Manage user access", code = ManageUserAccessRole.CODE)
public interface ManageUserAccessRole {
@ResourceRole(name = "Multitenancy: user management", code = TenantUserManagementRole.CODE)
public interface TenantUserManagementRole extends TenantManagementRole {

String CODE = "manage-user-access";
String CODE = "tenant-user-management-role";

@EntityPolicy(entityClass = User.class, actions = {EntityPolicyAction.ALL})
@EntityAttributePolicy(entityClass = User.class, attributes = "*", action = EntityAttributePolicyAction.MODIFY)
@ScreenPolicy(screenIds = {"mtensmp_User.browse", "mtensmp_User.edit"})
@MenuPolicy(menuIds = {"mtensmp_User.browse"})
@ScreenPolicy(screenIds = {"<UserBrowse_screen_id>", "UserEdit_screen_id"})
@MenuPolicy(menuIds = {"<UserBrowse_screen_id>"})
void createUserAccess();
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ private void initField(TextField<?> textField, Predicate<Tenant> predicate, Stri
.all()
.list()
.stream()
.filter(predicate)
.anyMatch(tenant -> tenant.getTenantId().equals(s));
.anyMatch(predicate);
if (exist) {
throw new ValidationException(messages.getMessage(messageKey));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
import io.jmix.securityui.role.annotation.ScreenPolicy;
import io.jmix.securityui.screen.resourcepolicy.AttributeResourceModel;

@ResourceRole(name = "Multitenancy: administration", code = MultitenancyAdminRole.CODE)
public interface MultitenancyAdminRole {
@ResourceRole(name = "Multitenancy: management", code = TenantManagementRole.CODE)
public interface TenantManagementRole {

String CODE = "multitenancy-admin-role";
String CODE = "tenant-management-role";

@EntityPolicy(entityClass = Tenant.class, actions = {EntityPolicyAction.READ})
@EntityPolicy(entityClass = BaseRoleModel.class, actions = {EntityPolicyAction.ALL})
Expand Down

0 comments on commit 0d45c27

Please sign in to comment.