pub(crate) struct AdminCheckWrapper {
pub(crate) _marker: PhantomData<()>,
pub(crate) function_component: FunctionComponent<Self>,
}Expand description
Wrapper component that checks if an admin exists before rendering children.
This component is used to gate access to pages that should only be accessible before
system initialization (e.g., login page). It performs an asynchronous check to the
backend’s /api/check-admin endpoint (via crate::handlers::auth::check_admin_exists) to determine system state.
§Behavior
- Loading: Displays “Loading…” while checking admin status from the backend
- No Admin: Automatically redirects to
Route::Setuppage for initialization - Admin Exists: Renders the wrapped children (e.g., login page)
§Example Usage
ⓘ
<AdminCheckWrapper>
<LoginPage />
</AdminCheckWrapper>§Backend Integration
The check queries the backend’s /api/check-admin endpoint which returns {"has_admin": bool}.
This allows the frontend to determine if initial admin setup is required.
Fields§
§_marker: PhantomData<()>§function_component: FunctionComponent<Self>Trait Implementations§
Source§impl BaseComponent for AdminCheckWrapperwhere
Self: 'static,
impl BaseComponent for AdminCheckWrapperwhere
Self: 'static,
Source§type Properties = AdminCheckWrapperProps
type Properties = AdminCheckWrapperProps
The Component’s Properties.
Source§fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool
fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool
Updates component’s internal state.
Source§fn changed(
&mut self,
_ctx: &Context<Self>,
_old_props: &Self::Properties,
) -> bool
fn changed( &mut self, _ctx: &Context<Self>, _old_props: &Self::Properties, ) -> bool
React to changes of component properties.
Source§fn rendered(&mut self, _ctx: &Context<Self>, _first_render: bool)
fn rendered(&mut self, _ctx: &Context<Self>, _first_render: bool)
Notified after a layout is rendered.
Source§fn prepare_state(&self) -> Option<String>
fn prepare_state(&self) -> Option<String>
Prepares the server-side state.
Source§impl Debug for AdminCheckWrapper
impl Debug for AdminCheckWrapper
Source§impl FunctionProvider for AdminCheckWrapper
impl FunctionProvider for AdminCheckWrapper
Source§type Properties = AdminCheckWrapperProps
type Properties = AdminCheckWrapperProps
Properties for the Function Component.
Auto Trait Implementations§
impl !Freeze for AdminCheckWrapper
impl !RefUnwindSafe for AdminCheckWrapper
impl !Send for AdminCheckWrapper
impl !Sync for AdminCheckWrapper
impl Unpin for AdminCheckWrapper
impl !UnwindSafe for AdminCheckWrapper
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self to a value of a Properties struct.§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self to a value of a Properties struct.