I have created a role programmatically where the user with this role can create an user but the “add role” option always remains inactive. Thanks for any suggestions to fix this problem.
Here is the user creation screen where you see the Roles “Add” option is inactive.
Here is the user role created and assigned to this user:
@Role(name = AdminUserRole.NAME)
public class AdminUserRole extends AnnotatedRoleDefinition {
public final static String NAME = "AUTO_User_Admin";
@EntityAccess(entityClass = User.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE})
@EntityAccess(entityClass = UserRole.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE})
@EntityAccess(entityClass = UserExt.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE})
@EntityAccess(entityClass = com.haulmont.cuba.security.entity.Role.class, operations = {EntityOp.READ})
@EntityAccess(entityClass = Company.class, operations = {EntityOp.READ})
@EntityAccess(entityClass = Employee.class, operations = {EntityOp.READ})
@EntityAccess(entityClass = Salesperson.class, operations = {EntityOp.READ})
@EntityAccess(entityClass = CustomerProfile.class, operations = {EntityOp.READ})
@EntityAccess(entityClass = VendorProfile.class, operations = {EntityOp.READ})
@EntityAccess(entityClass = DistributionCentre.class, operations = {EntityOp.READ})
@EntityAccess(entityClass = Plant.class, operations = {EntityOp.READ})
@EntityAccess(entityClass = CompanyAccess.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE})
@EntityAccess(entityClass = PlantAccess.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE})
@Override
public EntityPermissionsContainer entityPermissions() {
return super.entityPermissions();
}
@EntityAttributeAccess(entityClass = User.class, modify = "*")
@EntityAttributeAccess(entityClass = UserRole.class, modify = "*")
@EntityAttributeAccess(entityClass = UserExt.class, modify = "*")
@EntityAttributeAccess(entityClass = com.haulmont.cuba.security.entity.Role.class, modify = "*")
@EntityAttributeAccess(entityClass = Company.class, modify = "*")
@EntityAttributeAccess(entityClass = Employee.class, modify = "*")
@EntityAttributeAccess(entityClass = Salesperson.class, modify = "*")
@EntityAttributeAccess(entityClass = CustomerProfile.class, modify = "*")
@EntityAttributeAccess(entityClass = VendorProfile.class, modify = "*")
@EntityAttributeAccess(entityClass = DistributionCentre.class, modify = "*")
@EntityAttributeAccess(entityClass = Plant.class, modify = "*")
@EntityAttributeAccess(entityClass = PlantAccess.class, modify = "*")
@EntityAttributeAccess(entityClass = CompanyAccess.class, modify = "*")
@Override
public EntityAttributePermissionsContainer entityAttributePermissions() {
return super.entityAttributePermissions();
}
@ScreenAccess(screenIds = {"administration","mnuSystemAdmin", "sec$User.browse", "sec$User.edit", "erp_UserExt.browse", "erp_UserExt.edit", "sec$Role.browse"})
@Override
public ScreenPermissionsContainer screenPermissions() {
return super.screenPermissions();
}
Another:
@com.haulmont.cuba.security.app.role.annotation.Role(name = AdminUserRolesRole.NAME)
public class AdminUserRolesRole extends AnnotatedRoleDefinition {
public final static String NAME = “AUTO_USER_ROLE_ADMIN role”;@EntityAccess(entityClass = Group.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE}) @EntityAccess(entityClass = Role.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE}) @EntityAccess(entityClass = UserRole.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE}) @EntityAccess(entityClass = UserSessionEntity.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE}) @EntityAccess(entityClass = ScheduledTask.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE}) @EntityAccess(entityClass = SessionLogEntry.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE}) @EntityAccess(entityClass = EmailTemplate.class, operations = {EntityOp.CREATE, EntityOp.READ, EntityOp.UPDATE, EntityOp.DELETE}) @Override public EntityPermissionsContainer entityPermissions() { return super.entityPermissions(); } @EntityAttributeAccess(entityClass = Group.class, modify = "*") @EntityAttributeAccess(entityClass = Role.class, modify = "*") @EntityAttributeAccess(entityClass = UserRole.class, modify = "*") @EntityAttributeAccess(entityClass = UserSessionEntity.class, modify = "*") @EntityAttributeAccess(entityClass = ScheduledTask.class, modify = "*") @EntityAttributeAccess(entityClass = SessionLogEntry.class, modify = "*") @EntityAttributeAccess(entityClass = EmailTemplate.class, modify = "*") @Override public EntityAttributePermissionsContainer entityAttributePermissions() { return super.entityAttributePermissions(); } @ScreenAccess(screenIds = {"administration", "sec$Group.browse", "sec$Group.edit", "sec$Role.browse", "sec$Role.edit", "sec$UserSessionEntity.browse", "sec$SessionLogEntity.browse" //"sys$ScheduledTask.browse", "sys$ScheduledTask.edit", , "performanceStatistics" //,"emailtemplates$EmailTemplate.browse","emailtemplates$EmailTemplate.edit" }) @Override public ScreenPermissionsContainer screenPermissions() { return super.screenPermissions(); }
}