Skip to main content

ForceLoginUser

Trait ForceLoginUser 

Source
pub trait ForceLoginUser: Send + Sync {
    // Required method
    fn session_user_id(&self) -> String;

    // Provided methods
    fn session_is_staff(&self) -> bool { ... }
    fn session_is_superuser(&self) -> bool { ... }
}
Expand description

Trait for extracting session-storable identity from any user type.

Blanket-implemented for all AuthIdentity types (generated by the #[user] macro). Users with custom user types that don’t use #[user] can implement this trait directly.

Required Methods§

Source

fn session_user_id(&self) -> String

The user ID to store as "user_id" in session data.

Provided Methods§

Source

fn session_is_staff(&self) -> bool

Whether the user has staff privileges. Defaults to false.

Override via the builder’s .with_staff(true) if your user type implements FullUser but this blanket impl returns false.

Source

fn session_is_superuser(&self) -> bool

Whether the user has superuser privileges. Defaults to false.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<T: AuthIdentity> ForceLoginUser for T

Available on native only.