pub struct AuthManager { /* private fields */ }
Expand description
Manages authentication state and session tokens with enhanced security
Implementations§
Source§impl AuthManager
impl AuthManager
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Checks if the user is authenticated with a valid, non-expired token
Sourcepub fn session_token(&self) -> Option<&str>
pub fn session_token(&self) -> Option<&str>
Gets the current session token if valid and not expired
Sourcepub fn get_session_id(&self) -> Option<String>
pub fn get_session_id(&self) -> Option<String>
Gets the session ID (same as session token)
Sourcepub fn current_user(&self) -> Option<&User>
pub fn current_user(&self) -> Option<&User>
Gets the current user information
Sourcepub fn set_session(&mut self, token: String, user: User)
pub fn set_session(&mut self, token: String, user: User)
Sets the session information with secure token storage
Sourcepub fn set_session_with_ttl(
&mut self,
token: String,
user: User,
ttl: Option<Duration>,
)
pub fn set_session_with_ttl( &mut self, token: String, user: User, ttl: Option<Duration>, )
Sets the session information with token expiry
Sourcepub fn clear_session(&mut self)
pub fn clear_session(&mut self)
Clears the session information
Trait Implementations§
Source§impl Clone for AuthManager
impl Clone for AuthManager
Source§fn clone(&self) -> AuthManager
fn clone(&self) -> AuthManager
Returns a duplicate of the value. Read more
1.0.0 · 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 AuthManager
impl Debug for AuthManager
Auto Trait Implementations§
impl Freeze for AuthManager
impl RefUnwindSafe for AuthManager
impl Send for AuthManager
impl Sync for AuthManager
impl Unpin for AuthManager
impl UnwindSafe for AuthManager
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