Role entity represents a role for the application. It should be derived from AbpRole class as shown below:
public class Role : AbpRole<Tenant, User>
{
//add your own role properties here
}
This class is created when you install module-zero. Roles are stored in AbpRoles table in the database. You can add your custom properties to Role class (and create database migrations for the changes).
AbpRole defines some properties. Most importants are:
Roles are used to group permissions. When a user has a role, then he/she will have all permissions of that role. A user can have multiple roles. Permissions of this user will be a merge of all permissions of all assigned roles.
In module-zero, roles can be dynamic or static:
Use IsStatic property to set it for a role. Also, we should register static roles on PreInitialize of our module. Assume that we have an "Admin" static role for tenants:
Configuration.Modules.Zero().RoleManagement.StaticRoles.Add(new StaticRoleDefinition("Admin", MultiTenancySides.Tenant));
Thus, module-zero will be aware of static roles.
One or more roles can be set as default. Default roles are assigned to new added/registered users as default. This is not a development time property and can be set or changed after deployment. Use IsDefault property to set it.
RoleManager is a service to perform domain logic for roles:
public class RoleManager : AbpRoleManager<Tenant, Role, User>
{
//...
}
You can inject and use RoleManager to create, delete, update roles, grant permissions for roles and much more. You can add your own methods here. Also, you can override any method of AbpRoleManager base class for your own needs.
Like UserManager, Some methods of RoleManager also return IdentityResult as a result instead of throwing exceptions for some cases. See user management document for more information.
Similar to user management, role management also works for single tenant in one time in a multi-tenant application. See user management document for more information.