pub struct AccountLockManager { /* private fields */ }Expand description
Account lock manager for tracking failed attempts and locking accounts.
Implementations§
Source§impl AccountLockManager
impl AccountLockManager
Sourcepub fn new(config: LockConfig) -> AccountLockManager
pub fn new(config: LockConfig) -> AccountLockManager
Create a new account lock manager with the given configuration.
Sourcepub fn with_defaults() -> AccountLockManager
pub fn with_defaults() -> AccountLockManager
Create with default configuration.
Sourcepub async fn get_lock_status(&self, identifier: &str) -> LockStatus
pub async fn get_lock_status(&self, identifier: &str) -> LockStatus
Get the lock status for an account.
Sourcepub async fn get_failed_attempts(&self, identifier: &str) -> u32
pub async fn get_failed_attempts(&self, identifier: &str) -> u32
Get the number of recent failed attempts.
Sourcepub async fn get_remaining_attempts(&self, identifier: &str) -> u32
pub async fn get_remaining_attempts(&self, identifier: &str) -> u32
Get remaining attempts before lockout.
Sourcepub async fn record_failure(&self, identifier: &str) -> LockStatus
pub async fn record_failure(&self, identifier: &str) -> LockStatus
Record a failed login attempt.
Returns the new lock status after recording the failure.
Sourcepub async fn record_failure_with_ip(
&self,
identifier: &str,
ip_address: Option<&str>,
) -> LockStatus
pub async fn record_failure_with_ip( &self, identifier: &str, ip_address: Option<&str>, ) -> LockStatus
Record a failed login attempt with IP address.
Sourcepub async fn record_success(&self, identifier: &str)
pub async fn record_success(&self, identifier: &str)
Record a successful login.
This resets the failed attempt counter if reset_on_success is enabled.
Sourcepub async fn lock_permanently(&self, identifier: &str, reason: &str)
pub async fn lock_permanently(&self, identifier: &str, reason: &str)
Manually lock an account permanently.
Sourcepub async fn get_account_stats(&self, identifier: &str) -> AccountStats
pub async fn get_account_stats(&self, identifier: &str) -> AccountStats
Get statistics for an account.
Trait Implementations§
Source§impl Clone for AccountLockManager
impl Clone for AccountLockManager
Source§fn clone(&self) -> AccountLockManager
fn clone(&self) -> AccountLockManager
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 Default for AccountLockManager
impl Default for AccountLockManager
Source§fn default() -> AccountLockManager
fn default() -> AccountLockManager
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for AccountLockManager
impl !RefUnwindSafe for AccountLockManager
impl Send for AccountLockManager
impl Sync for AccountLockManager
impl Unpin for AccountLockManager
impl !UnwindSafe for AccountLockManager
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more