Rename Authenticator to UserAuthenticator
This commit is contained in:
parent
ffd3a95076
commit
e56c7525e2
1 changed files with 6 additions and 6 deletions
12
src/auth.rs
12
src/auth.rs
|
@ -31,12 +31,12 @@ pub enum AuthenticationError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Authenticator {
|
pub struct UserAuthenticator {
|
||||||
db: Arc<Mutex<SqliteDatabase>>,
|
db: Arc<Mutex<SqliteDatabase>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Authenticator {
|
impl UserAuthenticator {
|
||||||
const USER_TOKEN_LEN: usize = 30;
|
const TOKEN_LEN: usize = 30;
|
||||||
|
|
||||||
pub fn new(db: Arc<Mutex<SqliteDatabase>>) -> Self {
|
pub fn new(db: Arc<Mutex<SqliteDatabase>>) -> Self {
|
||||||
Self { db }
|
Self { db }
|
||||||
|
@ -45,7 +45,7 @@ impl Authenticator {
|
||||||
#[instrument]
|
#[instrument]
|
||||||
pub async fn create_user_token(&mut self, username: &str, password: &Password) -> UserToken {
|
pub async fn create_user_token(&mut self, username: &str, password: &Password) -> UserToken {
|
||||||
let new_token =
|
let new_token =
|
||||||
UserToken::from(Alphanumeric.sample_string(&mut thread_rng(), Self::USER_TOKEN_LEN));
|
UserToken::from(Alphanumeric.sample_string(&mut thread_rng(), Self::TOKEN_LEN));
|
||||||
|
|
||||||
let mut db = self.db.lock().await;
|
let mut db = self.db.lock().await;
|
||||||
if let Err(err) = db.save_token(username, &new_token).await {
|
if let Err(err) = db.save_token(username, &new_token).await {
|
||||||
|
@ -85,12 +85,12 @@ impl ServerPadlockGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UserServerKeyGenerator {
|
pub struct UserServerKeyGenerator {
|
||||||
user_authenticator: Arc<Authenticator>,
|
user_authenticator: Arc<UserAuthenticator>,
|
||||||
padlock_generator: Arc<ServerPadlockGenerator>,
|
padlock_generator: Arc<ServerPadlockGenerator>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UserServerKeyGenerator {
|
impl UserServerKeyGenerator {
|
||||||
pub fn new(/* Authenticator, ServerPadlockGenerator? */) -> Self {
|
pub fn new(/* UserAuthenticator, ServerPadlockGenerator? */) -> Self {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue