Hi
New roles are applied to new created tenants only. Do you have an option to create a new role for existing tenants as well? I sometimes have migrations that not only envolve schema updates but also data (Seed data for all tenants) and I'm not sure if you have guidelines that help managing this
Thanks
8 Answer(s)
-
0
What do you mean roles in tenant? Roles are defined on users.
-
0
Yes. But every tenant has roles. When I configure static roles in the system they aren't added to existing tenants but new tenants only. I need them to be added to existing tenants as well
-
0
any news?
-
0
hi @kasem
Try the following code for the tenant to create the missing static role.
public virtual async Task<IdentityResult> CreateTenantStaticRoles(int tenantId) { var staticRoleDefinitions = _roleManagementConfig.StaticRoles.Where(sr => sr.Side == MultiTenancySides.Tenant); using (_unitOfWorkManager.Current.SetTenantId(tenantId)) { foreach (var staticRoleDefinition in staticRoleDefinitions) { if (await _roleManager.FindByNameAsync(staticRoleDefinition.RoleName) == null) { var role = new Role { TenantId = tenantId, Name = staticRoleDefinition.RoleName, DisplayName = staticRoleDefinition.RoleName, IsStatic = true }; var identityResult = await _roleManager.CreateAsync(role); if (!identityResult.Succeeded) { return identityResult; } } } } return IdentityResult.Success; }
-
0
Hi @kasem. It is designed this way from the start. So it is an expected scenario.
You can use @maliming solution.
-
0
Thanks @maliming and @demirmusa
@demirmusa, what do you mean by "It is designed this way from the start"?
-
0
If you add a new static role you should handle adding it to all previous tenants.
-
0
This issue is closed because it has not had recent activity for a long time.