SudoSOS Back-end API / rbac / RoleUserType
Class: RoleUserType ​
The RoleUserType entity represents the many-to-many relationship between user types and roles in the Role-Based Access Control (RBAC) system. This entity enables automatic role assignment based on a user's type.
Purpose and Usage ​
RoleUserType allows the system to automatically assign roles to users based on their user type, eliminating the need for manual role assignment for common user categories. This is the primary mechanism for role assignment in the RBAC system.
User Types and Role Assignment ​
Different user types receive different sets of roles:
- MEMBER: Regular association members with basic access
- LOCAL_USER: Local users with limited permissions
- LOCAL_ADMIN: Local administrators with elevated privileges
- ORGAN: Organization accounts with specific permissions
- VOUCHER: Voucher accounts with restricted access
- INVOICE: Invoice-related accounts
- POINT_OF_SALE: Point of sale system accounts
Automatic Role Assignment Flow ​
- User Creation: When a user is created with a specific user type
- Role Lookup: System queries RoleUserType for roles associated with that user type
- Role Assignment: User automatically receives all roles linked to their user type
- Permission Evaluation: RoleManager uses these roles for permission checks
Relationship Model ​
- Role: Each relationship links a specific role to a user type
- UserType: Each relationship specifies which user type receives the role
- Composite Key: The combination of roleId and userType forms a unique constraint
Database Design ​
The entity uses a composite primary key (roleId, userType) to ensure that each role can only be assigned once per user type. The relationship includes cascade behavior for maintaining referential integrity.
Integration with Role Manager ​
The RoleManager's getRoles() method queries RoleUserType to determine which roles a user should have based on their user type, providing the foundation for permission evaluation.
Extends ​
BaseEntity
Constructors ​
Constructor ​
new RoleUserType(): RoleUserType;Returns ​
RoleUserType
Inherited from ​
BaseEntity.constructorProperties ​
| Property | Modifier | Type |
|---|---|---|
role | public | Role |
roleId | public | number |
userType | public | UserType |