Skip to main content

AdminUser

Trait AdminUser 

Source
pub trait AdminUser: Send + Sync {
    // Required methods
    fn is_active(&self) -> bool;
    fn is_staff(&self) -> bool;
    fn is_superuser(&self) -> bool;
    fn get_username(&self) -> &str;
}
Available on server only.
Expand description

Object-safe trait for admin permission checks.

This trait provides the minimum user information needed for admin permission decisions, without exposing generic type parameters from BaseUser or FullUser.

A blanket implementation is provided for all types implementing FullUser, so any custom user model with FullUser will automatically satisfy this trait.

For simpler user models that only implement BaseUser (without FullUser), this trait can be implemented manually to enable admin authentication.

Required Methods§

Source

fn is_active(&self) -> bool

Whether the user account is active

Source

fn is_staff(&self) -> bool

Whether the user is a staff member (can access admin)

Source

fn is_superuser(&self) -> bool

Whether the user is a superuser (all permissions granted)

Source

fn get_username(&self) -> &str

The username for audit logging

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<T: FullUser> AdminUser for T

Blanket implementation for all types implementing FullUser.

This ensures that any custom user model with FullUser implementation automatically satisfies AdminUser.