doc/WebSite/Zero/Role-Management.md
The Role entity represents a role for the application. It should be derived from the AbpRole class as shown below:
public class Role : AbpRole<Tenant, User>
{
//add your own role properties here
}
This class will be created when you download an ABP template with the option in the below image is selected.
Roles are stored in the AbpRoles table in the database. You can add your own custom properties to the Role class (and create database migrations for the changes).
AbpRole defines some properties. The most important are:
Roles are used to group permissions. When a user has a role, then he/she will have all the permissions of that role. A user can have multiple roles. The Permissions of this user will be a merge of all the permissions of all assigned roles.
In Module Zero, roles can be dynamic or static:
Use the IsStatic property to set it for a role. We must also register static roles in the PreInitialize method of our module. Assume that we have an "Admin" static role for tenants:
Configuration.Modules.Zero().RoleManagement.StaticRoles.Add(new StaticRoleDefinition("Admin", MultiTenancySides.Tenant));
This way, Module Zero will be aware of static roles.
One or more roles can be set as default. Default roles are assigned to newly added/registered users by default. This is not a development time property and can be set or changed after deployment. Use the 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 the RoleManager to create, delete, update roles, grant permissions for roles and much more. You can add your own methods here, too. You can also override any method of the AbpRoleManager base class for your own needs.
Like the UserManager, some methods of the RoleManager also return IdentityResult as a result instead of throwing exceptions. See the user management document for more information.
Similar to user management, role management also works for a tenant in a multi-tenant application. See the user management document for more information.