Skip to main content

Module auth_models

Module auth_models 

Source
Expand description

Frontend-facing authentication session models.

Orbital keeps browser-visible auth state intentionally small: enough information to personalize the UI, gate pages, and show account status without exposing the full backend user model. These types are the shared contract between the SSR session loader and the client-side component tree.

§Example

use orbital::{AnonymousUser, AuthSession, AuthenticatedUser};

let anonymous = AuthSession::Anonymous(AnonymousUser::default());
assert!(!anonymous.is_authenticated());
assert_eq!(anonymous.display_label(), "Guest");

let authenticated = AuthSession::Authenticated(AuthenticatedUser {
    user_id: "user-123".to_string(),
    email: Some("alex@example.com".to_string()),
    display_name: Some("Alex".to_string()),
    avatar_url: None,
    roles: vec!["admin".to_string()],
    email_verified: true,
});

assert!(authenticated.is_authenticated());
assert_eq!(authenticated.display_label(), "Alex");

Structs§

AnonymousUser
Additional context for an anonymous visitor.
AuthenticatedUser
Core identity and profile details for an authenticated user.

Enums§

AuthSession
Represents the current authentication session for the frontend.