use async_trait::async_trait;
use crate::{
fnd::{
identifier::{Uid, UserIdentifier},
secret_key::SecretArgsProvide,
},
prelude::*,
};
#[async_trait]
pub trait UserHandle: SecretArgsProvide {
async fn get_password_hash(
&self,
depot: &mut Depot,
identifier: &UserIdentifier,
) -> Result<UidPasswordHash, ApiError>;
async fn set_password_hash(
&self,
depot: &mut Depot,
identifier: &UserIdentifier,
password_hash: String,
) -> Result<(), ApiError>;
async fn get_totp_info(&self, depot: &mut Depot, identifier: &UserIdentifier) -> Result<UserTotpInfo, ApiError>;
async fn set_totp_secret(
&self,
depot: &mut Depot,
user_id: Uid,
totp_secret: String,
) -> Result<UserTotpInfo, ApiError>;
async fn enable_2fa(&self, depot: &mut Depot, user_id: Uid, enable_2fa: bool) -> Result<(), ApiError>;
}
#[allow(clippy::exhaustive_structs)]
pub struct UidPasswordHash {
pub user_id: Uid,
pub password_hash: String,
}
#[allow(clippy::exhaustive_structs)]
pub struct UserTotpInfo {
pub user_id: Uid,
pub username: String,
pub totp_secret: String,
pub enable_2fa: bool,
}