impl From<String> for {Password,UserToken}
This commit is contained in:
parent
9cd4848ce8
commit
e4aa6c1909
2 changed files with 11 additions and 1 deletions
10
src/auth.rs
10
src/auth.rs
|
@ -8,9 +8,19 @@ use tracing::instrument;
|
||||||
use crate::db::{Database, SqliteDatabase};
|
use crate::db::{Database, SqliteDatabase};
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct Password(pub SecretString);
|
pub struct Password(pub SecretString);
|
||||||
|
impl From<String> for Password {
|
||||||
|
fn from(value: String) -> Self {
|
||||||
|
Self(SecretString::new(value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct UserToken(pub SecretString);
|
pub struct UserToken(pub SecretString);
|
||||||
|
impl From<String> for UserToken {
|
||||||
|
fn from(value: String) -> Self {
|
||||||
|
Self(SecretString::new(value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Authenticator<DB: Database> {
|
pub struct Authenticator<DB: Database> {
|
||||||
|
|
|
@ -59,6 +59,6 @@ impl Database for SqliteDatabase {
|
||||||
.fetch_one(&mut self.conn)
|
.fetch_one(&mut self.conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(UserToken(SecretString::new(row.0)))
|
Ok(UserToken::from(row.0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue