pub struct OrganizationsPlugin { /* private fields */ }Expand description
Organizations plugin. Multi-tenant team management with roles.
Implementations§
Source§impl OrganizationsPlugin
impl OrganizationsPlugin
pub fn new() -> Self
Sourcepub fn create_org(&self, name: &str, creator_id: &str) -> Organization
pub fn create_org(&self, name: &str, creator_id: &str) -> Organization
Create a new organization. The creator becomes the owner.
Sourcepub fn add_member(
&self,
org_id: &str,
user_id: &str,
role: OrgRole,
) -> Result<(), String>
pub fn add_member( &self, org_id: &str, user_id: &str, role: OrgRole, ) -> Result<(), String>
Add a member to an organization.
Sourcepub fn remove_member(&self, org_id: &str, user_id: &str) -> bool
pub fn remove_member(&self, org_id: &str, user_id: &str) -> bool
Remove a member from an organization.
Sourcepub fn get_role(&self, org_id: &str, user_id: &str) -> Option<OrgRole>
pub fn get_role(&self, org_id: &str, user_id: &str) -> Option<OrgRole>
Get a user’s role in an organization.
Sourcepub fn list_members(&self, org_id: &str) -> Vec<Membership>
pub fn list_members(&self, org_id: &str) -> Vec<Membership>
List all members of an organization.
Sourcepub fn list_user_orgs(&self, user_id: &str) -> Vec<(Organization, OrgRole)>
pub fn list_user_orgs(&self, user_id: &str) -> Vec<(Organization, OrgRole)>
List all organizations a user belongs to.
Sourcepub fn is_member(&self, org_id: &str, user_id: &str) -> bool
pub fn is_member(&self, org_id: &str, user_id: &str) -> bool
Check if a user is a member of an organization.
Sourcepub fn delete_org(&self, org_id: &str) -> bool
pub fn delete_org(&self, org_id: &str) -> bool
Delete an organization and all its memberships.
Trait Implementations§
Source§impl Plugin for OrganizationsPlugin
impl Plugin for OrganizationsPlugin
Source§fn on_init(&self, _ctx: &PluginContext)
fn on_init(&self, _ctx: &PluginContext)
Called once when the plugin is registered.
Source§fn routes(&self) -> Vec<PluginRoute>
fn routes(&self) -> Vec<PluginRoute>
Custom API routes this plugin handles.
Source§fn before_insert(
&self,
_entity: &str,
_data: &mut Value,
_auth: &AuthContext,
) -> Result<(), PluginError>
fn before_insert( &self, _entity: &str, _data: &mut Value, _auth: &AuthContext, ) -> Result<(), PluginError>
Called before an entity insert. Return Err to reject.
Source§fn after_insert(
&self,
_entity: &str,
_id: &str,
_data: &Value,
_auth: &AuthContext,
)
fn after_insert( &self, _entity: &str, _id: &str, _data: &Value, _auth: &AuthContext, )
Called after a successful insert.
Source§fn before_update(
&self,
_entity: &str,
_id: &str,
_data: &mut Value,
_auth: &AuthContext,
) -> Result<(), PluginError>
fn before_update( &self, _entity: &str, _id: &str, _data: &mut Value, _auth: &AuthContext, ) -> Result<(), PluginError>
Called before an entity update. Return Err to reject.
Source§fn after_update(
&self,
_entity: &str,
_id: &str,
_data: &Value,
_auth: &AuthContext,
)
fn after_update( &self, _entity: &str, _id: &str, _data: &Value, _auth: &AuthContext, )
Called after a successful update.
Source§fn before_delete(
&self,
_entity: &str,
_id: &str,
_auth: &AuthContext,
) -> Result<(), PluginError>
fn before_delete( &self, _entity: &str, _id: &str, _auth: &AuthContext, ) -> Result<(), PluginError>
Called before an entity delete. Return Err to reject.
Source§fn after_delete(&self, _entity: &str, _id: &str, _auth: &AuthContext)
fn after_delete(&self, _entity: &str, _id: &str, _auth: &AuthContext)
Called after a successful delete.
Source§fn on_request(
&self,
_method: &str,
_path: &str,
_auth: &AuthContext,
) -> Result<(), PluginError>
fn on_request( &self, _method: &str, _path: &str, _auth: &AuthContext, ) -> Result<(), PluginError>
Called on every incoming request (middleware).
Source§fn on_request_with_meta(
&self,
method: &str,
path: &str,
auth: &AuthContext,
_meta: &RequestMeta<'_>,
) -> Result<(), PluginError>
fn on_request_with_meta( &self, method: &str, path: &str, auth: &AuthContext, _meta: &RequestMeta<'_>, ) -> Result<(), PluginError>
Richer variant of [
on_request] that also receives per-request
metadata (peer IP today; more fields may be added later). The
default implementation delegates to on_request so existing
plugins keep working without changes. Plugins that care about
IP — notably rate limiting — override this hook.Source§fn on_session_create(&self, _user_id: &str, _token: &str)
fn on_session_create(&self, _user_id: &str, _token: &str)
Called when a new session is created.
Source§fn entities(&self) -> Vec<ManifestEntity>
fn entities(&self) -> Vec<ManifestEntity>
Additional manifest entities this plugin contributes.
Auto Trait Implementations§
impl !Freeze for OrganizationsPlugin
impl RefUnwindSafe for OrganizationsPlugin
impl Send for OrganizationsPlugin
impl Sync for OrganizationsPlugin
impl Unpin for OrganizationsPlugin
impl UnsafeUnpin for OrganizationsPlugin
impl UnwindSafe for OrganizationsPlugin
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more