pub trait RequestUser {
// Required method
fn current_user(&self) -> Option<&IdentityUser>;
// Provided methods
fn user_id(&self) -> Option<&str> { ... }
fn user_name(&self) -> Option<&str> { ... }
fn user_email(&self) -> Option<&str> { ... }
fn tenant_id(&self) -> Option<&str> { ... }
fn roles(&self) -> &[String] { ... }
fn is_in_role(&self, role: &str) -> bool { ... }
fn require_user(&self) -> Result<&IdentityUser, Error> { ... }
}Expand description
Convenience accessors for a request that carries an IdentityUser.
#[derive(WebxRequestMeta)] implements this automatically when the struct
has a #[fromclaim] field of type IdentityUser or Option<IdentityUser>.
Required Methods§
Sourcefn current_user(&self) -> Option<&IdentityUser>
fn current_user(&self) -> Option<&IdentityUser>
The authenticated identity, or None for an anonymous request.
Provided Methods§
Sourcefn user_email(&self) -> Option<&str>
fn user_email(&self) -> Option<&str>
The email address, or None when anonymous.
Sourcefn is_in_role(&self, role: &str) -> bool
fn is_in_role(&self, role: &str) -> bool
Whether the authenticated user has role.
Sourcefn require_user(&self) -> Result<&IdentityUser, Error>
fn require_user(&self) -> Result<&IdentityUser, Error>
The identity, or 401 Unauthorized when the request is anonymous.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".