Skip to main content

PanelUser

Trait PanelUser 

Source
pub trait PanelUser:
    Any
    + Send
    + Sync {
    // Required methods
    fn user_id(&self) -> String;
    fn display_name(&self) -> &str;

    // Provided methods
    fn can_access_panel(&self) -> bool { ... }
    fn tenants(&self) -> &[Membership] { ... }
}
Expand description

A signed-in user, as the panel knows it (ADR-0013).

Implement it for the app’s own user type and return that type from an Authenticator; the shipped AdminUser implements it too. App code reads the user back with its own type through user.

impl PanelUser for Staff {
    fn user_id(&self) -> String {
        self.id.to_string()
    }
    fn display_name(&self) -> &str {
        &self.name
    }
    fn can_access_panel(&self) -> bool {
        self.active
    }
    fn tenants(&self) -> &[Membership] {
        &self.memberships
    }
}

Required Methods§

Source

fn user_id(&self) -> String

The stable key the session stores and Authenticator::find_by_id receives. Any string fits.

Source

fn display_name(&self) -> &str

The name the panel’s top bar shows.

Provided Methods§

Source

fn can_access_panel(&self) -> bool

Whether the user may enter the panel. A user who may not answers 403, indistinguishable from bad credentials at login. Defaults to true.

Source

fn tenants(&self) -> &[Membership]

The tenants the user may act for, in the order the tenant switcher lists them. The first is the default tenant until the user selects another. Defaults to none: the user has no tenant.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§