updated api to create totp struct, get totp secret directly if it exists

This commit is contained in:
Philippe Loctaux 2023-05-01 11:48:57 +02:00
parent e70d035c86
commit f891d2f940
4 changed files with 18 additions and 20 deletions

View file

@ -50,7 +50,10 @@ impl User {
)
}
async fn get_by_id(conn: impl SqliteExecutor<'_>, id: &UserID) -> Result<Option<Self>, Error> {
pub async fn get_by_id(
conn: impl SqliteExecutor<'_>,
id: &UserID,
) -> Result<Option<Self>, Error> {
Ok(DatabaseUsers::get_one_by_id(conn, &id.0)
.await?
.map(Self::from))

View file

@ -57,7 +57,7 @@ impl User {
pub fn paper_key_hashed(&self) -> Option<&str> {
self.paper_key.as_deref()
}
pub fn is_totp_enabled(&self) -> bool {
self.totp_secret.is_some()
pub fn totp_secret(&self) -> Option<Vec<u8>> {
self.totp_secret.clone()
}
}