Refined docs and stuff
Docs link to each other and are generally better
This commit is contained in:
@@ -33,14 +33,14 @@ pub struct ProtectedRouteProps {
|
||||
|
||||
/// A component that protects routes by enforcing authentication and optional administrator privileges.
|
||||
///
|
||||
/// This component fetches the current user's authentication and admin status from the
|
||||
/// `/api/users/current` endpoint upon mounting. Based on the `AuthState` and the
|
||||
/// `admin_page` property, it either renders its children or redirects the user.
|
||||
/// This component uses the backend's validation middleware by fetching the current user's authentication
|
||||
/// and admin status from the `/api/users/current` endpoint (which requires a valid JWT token).
|
||||
/// Based on the [`AuthState`] and the `admin_page` property, it either renders its children or redirects the user.
|
||||
///
|
||||
/// # Behavior
|
||||
/// - **Initial Load**: Displays "Loading..." while checking authentication status.
|
||||
/// - **Initial Load**: Displays "Loading..." while checking authentication status via the backend.
|
||||
/// - **Not Authenticated**: Redirects to the login page (`crate::Route::Login`).
|
||||
/// - **Authenticated**:
|
||||
/// - **Authenticated** (valid JWT token from backend):
|
||||
/// - If `admin_page` is `true`:
|
||||
/// - If the user is an administrator (`is_admin: Some(true)`), it renders `children`.
|
||||
/// - If the user is not an administrator (`is_admin: Some(false)`), it redirects to
|
||||
|
||||
Reference in New Issue
Block a user