Overview
TheWirechatUser contract defines the authorization interface that your User model must implement to control access to WireChat features. This contract ensures users have proper permissions for creating chats, groups, and accessing the WireChat panel.
Contract Location
Implementation
Your User model must implement this contract:Required Methods
canCreateGroups()
Determine if the user can create new groups.Returns
true if the user is allowed to create groups, false otherwiseThis method is called before allowing users to access group creation forms or process group creation requests.
canCreateChats()
Determine if the user can create new chats with other users.Returns
true if the user is allowed to create private chats, false otherwiseThis permission is checked when users attempt to start private conversations with other users.
canAccessWirechatPanel()
Determine if the user can access the WireChat panel.The panel instance being accessed
Returns
true if the user can access the specified panel, false otherwiseMultiple panels can be registered in WireChat. This method receives the specific panel being accessed, allowing for granular access control.
Complete Example
Here’s a complete implementation example:Authorization Flow
Feature-Specific Checks
When creating groups:
canCreateGroups() is calledWhen creating chats: canCreateChats() is calledRelated
- InteractsWithWirechat Trait - Provides chat functionality methods
- Configuration - Learn about panel configuration