pub struct AdminAuthenticatedUser(pub Arc<dyn AdminUser>);Available on
server only.Expand description
Type-erased authenticated admin user.
This replaces the hardcoded CurrentUser<AdminDefaultUser> in admin server
functions. It loads the user from the database using whichever concrete
user type was registered via AdminSite::set_user_type. If no custom
type was registered, AdminDefaultUser is used as a fallback.
The inner Arc<dyn AdminUser> provides access to authentication and
permission methods without exposing the concrete user type. Arc is
used instead of Box because the #[server_fn] macro requires
injected types to implement Clone.
§Usage in server functions
ⓘ
use crate::server::admin_auth::AdminAuthenticatedUser;
#[server_fn]
pub async fn my_admin_endpoint(
#[inject] AdminAuthenticatedUser(user): AdminAuthenticatedUser,
) -> Result<(), ServerFnError> {
// user is Arc<dyn AdminUser>
if user.is_superuser() {
// ...
}
Ok(())
}Tuple Fields§
§0: Arc<dyn AdminUser>Trait Implementations§
Source§impl Clone for AdminAuthenticatedUser
impl Clone for AdminAuthenticatedUser
Source§fn clone(&self) -> AdminAuthenticatedUser
fn clone(&self) -> AdminAuthenticatedUser
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AdminAuthenticatedUser
impl Debug for AdminAuthenticatedUser
Source§impl Injectable for AdminAuthenticatedUser
impl Injectable for AdminAuthenticatedUser
Auto Trait Implementations§
impl !RefUnwindSafe for AdminAuthenticatedUser
impl !UnwindSafe for AdminAuthenticatedUser
impl Freeze for AdminAuthenticatedUser
impl Send for AdminAuthenticatedUser
impl Sync for AdminAuthenticatedUser
impl Unpin for AdminAuthenticatedUser
impl UnsafeUnpin for AdminAuthenticatedUser
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more