use crate::error::Result;
use async_trait::async_trait;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum MfaStatus {
Disabled,
Pending,
Enabled,
}
#[async_trait]
pub trait MfaStore: Send + Sync {
async fn get_totp_secret(&self, user_id: &str) -> Result<Option<String>>;
async fn set_totp_secret(&self, user_id: &str, secret: &str) -> Result<()>;
async fn enable_totp(&self, user_id: &str) -> Result<()>;
async fn disable_totp(&self, user_id: &str) -> Result<()>;
async fn get_mfa_status(&self, user_id: &str) -> Result<MfaStatus>;
async fn get_backup_codes(&self, user_id: &str) -> Result<Vec<String>>;
async fn set_backup_codes(&self, user_id: &str, codes: &[String]) -> Result<()>;
async fn remove_backup_code(&self, user_id: &str, index: usize) -> Result<()>;
async fn backup_codes_remaining(&self, user_id: &str) -> Result<usize> {
Ok(self.get_backup_codes(user_id).await?.len())
}
}