pub struct SessionManager { /* private fields */ }Expand description
Session manager handles CSRF tokens and authentication state
Implementations§
Source§impl SessionManager
impl SessionManager
pub fn new(http_client: HttpClient, base_url: Url) -> Self
Sourcepub async fn get_csrf_token(&self) -> Result<String>
pub async fn get_csrf_token(&self) -> Result<String>
Get the current CSRF token, fetching one if needed
Sourcepub async fn refresh_csrf_token(&self) -> Result<String>
pub async fn refresh_csrf_token(&self) -> Result<String>
Refresh the CSRF token by fetching from the token endpoint
pub async fn clear_session(&self)
pub async fn is_authenticated(&self) -> bool
Sourcepub async fn invalidate_session(&self)
pub async fn invalidate_session(&self)
Mark session as invalidated (e.g., after getting 401)
Sourcepub async fn mark_authenticated(&self, username: &str)
pub async fn mark_authenticated(&self, username: &str)
Mark user as authenticated
pub async fn current_username(&self) -> Option<String>
pub async fn last_auth_time(&self) -> Option<DateTime<Utc>>
Sourcepub async fn is_session_expired(&self, max_age_minutes: u64) -> bool
pub async fn is_session_expired(&self, max_age_minutes: u64) -> bool
Check if the session is expired (based on time)
Sourcepub async fn update_token_from_headers(&self, headers: &HeaderMap)
pub async fn update_token_from_headers(&self, headers: &HeaderMap)
Update CSRF token from response headers if available
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SessionManager
impl !UnwindSafe for SessionManager
impl Freeze for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl UnsafeUnpin for SessionManager
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