impl From<String> for {Password,UserToken}

This commit is contained in:
deneb 2024-02-10 12:30:04 +01:00
parent 9cd4848ce8
commit e4aa6c1909
2 changed files with 11 additions and 1 deletions

View file

@ -8,9 +8,19 @@ use tracing::instrument;
use crate::db::{Database, SqliteDatabase};
#[derive(Debug, Clone, Deserialize)]
pub struct Password(pub SecretString);
impl From<String> for Password {
fn from(value: String) -> Self {
Self(SecretString::new(value))
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct UserToken(pub SecretString);
impl From<String> for UserToken {
fn from(value: String) -> Self {
Self(SecretString::new(value))
}
}
#[derive(Debug)]
pub struct Authenticator<DB: Database> {

View file

@ -59,6 +59,6 @@ impl Database for SqliteDatabase {
.fetch_one(&mut self.conn)
.await?;
Ok(UserToken(SecretString::new(row.0)))
Ok(UserToken::from(row.0))
}
}