pub struct TwoFactorUseCases { /* private fields */ }Expand description
Use cases for two-factor authentication (TOTP)
Implementations§
Source§impl TwoFactorUseCases
impl TwoFactorUseCases
pub fn new( two_factor_repo: Arc<dyn TwoFactorRepository>, user_repo: Arc<dyn UserRepository>, encryption_key: [u8; 32], ) -> Self
Sourcepub async fn setup_2fa(
&self,
user_id: Uuid,
organization_id: Uuid,
) -> Result<Setup2FAResponseDto, String>
pub async fn setup_2fa( &self, user_id: Uuid, organization_id: Uuid, ) -> Result<Setup2FAResponseDto, String>
Setup 2FA for a user (returns QR code + backup codes) This does NOT enable 2FA yet - user must verify with TOTP code first
Sourcepub async fn enable_2fa(
&self,
user_id: Uuid,
organization_id: Uuid,
dto: Enable2FADto,
) -> Result<Enable2FAResponseDto, String>
pub async fn enable_2fa( &self, user_id: Uuid, organization_id: Uuid, dto: Enable2FADto, ) -> Result<Enable2FAResponseDto, String>
Enable 2FA after user verifies TOTP code
Sourcepub async fn verify_2fa(
&self,
user_id: Uuid,
organization_id: Uuid,
dto: Verify2FADto,
) -> Result<Verify2FAResponseDto, String>
pub async fn verify_2fa( &self, user_id: Uuid, organization_id: Uuid, dto: Verify2FADto, ) -> Result<Verify2FAResponseDto, String>
Verify TOTP code or backup code during login
Sourcepub async fn disable_2fa(
&self,
user_id: Uuid,
organization_id: Uuid,
dto: Disable2FADto,
) -> Result<(), String>
pub async fn disable_2fa( &self, user_id: Uuid, organization_id: Uuid, dto: Disable2FADto, ) -> Result<(), String>
Disable 2FA (requires current password verification)
Sourcepub async fn regenerate_backup_codes(
&self,
user_id: Uuid,
organization_id: Uuid,
dto: RegenerateBackupCodesDto,
) -> Result<RegenerateBackupCodesResponseDto, String>
pub async fn regenerate_backup_codes( &self, user_id: Uuid, organization_id: Uuid, dto: RegenerateBackupCodesDto, ) -> Result<RegenerateBackupCodesResponseDto, String>
Regenerate backup codes (requires TOTP verification)
Sourcepub async fn get_2fa_status(
&self,
user_id: Uuid,
) -> Result<TwoFactorStatusDto, String>
pub async fn get_2fa_status( &self, user_id: Uuid, ) -> Result<TwoFactorStatusDto, String>
Get 2FA status for a user
Auto Trait Implementations§
impl Freeze for TwoFactorUseCases
impl !RefUnwindSafe for TwoFactorUseCases
impl Send for TwoFactorUseCases
impl Sync for TwoFactorUseCases
impl Unpin for TwoFactorUseCases
impl !UnwindSafe for TwoFactorUseCases
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
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moreCreates a shared type from an unshared type.