pub struct TotpManager { /* private fields */ }Expand description
TOTP manager for handling time-based one-time passwords
Implementations§
Source§impl TotpManager
impl TotpManager
Sourcepub fn new(storage: Arc<dyn AuthStorage>) -> Self
pub fn new(storage: Arc<dyn AuthStorage>) -> Self
Create a new TOTP manager
Sourcepub async fn generate_secret(&self, user_id: &str) -> Result<String>
pub async fn generate_secret(&self, user_id: &str) -> Result<String>
Generate TOTP secret for a user
Sourcepub async fn generate_qr_code(
&self,
user_id: &str,
app_name: &str,
secret: &str,
) -> Result<String>
pub async fn generate_qr_code( &self, user_id: &str, app_name: &str, secret: &str, ) -> Result<String>
Generate TOTP QR code URL
Sourcepub async fn generate_code(&self, secret: &str) -> Result<String>
pub async fn generate_code(&self, secret: &str) -> Result<String>
Generate current TOTP code using provided secret
Sourcepub async fn generate_code_for_window(
&self,
secret: &str,
time_window: Option<u64>,
) -> Result<String>
pub async fn generate_code_for_window( &self, secret: &str, time_window: Option<u64>, ) -> Result<String>
Generate TOTP code for given secret and optional specific time window
Sourcepub async fn verify_code(&self, user_id: &str, code: &str) -> Result<bool>
pub async fn verify_code(&self, user_id: &str, code: &str) -> Result<bool>
Verify TOTP code for a user
Sourcepub async fn has_totp_secret(&self, user_id: &str) -> Result<bool>
pub async fn has_totp_secret(&self, user_id: &str) -> Result<bool>
Check if user has TOTP secret configured
Auto Trait Implementations§
impl Freeze for TotpManager
impl !RefUnwindSafe for TotpManager
impl Send for TotpManager
impl Sync for TotpManager
impl Unpin for TotpManager
impl !UnwindSafe for TotpManager
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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