Rename Authenticator to UserAuthenticator

This commit is contained in:
Xiretza 2024-02-10 12:35:05 +00:00
parent ffd3a95076
commit e56c7525e2

View file

@ -31,12 +31,12 @@ pub enum AuthenticationError {
}
#[derive(Debug)]
pub struct Authenticator {
pub struct UserAuthenticator {
db: Arc<Mutex<SqliteDatabase>>,
}
impl Authenticator {
const USER_TOKEN_LEN: usize = 30;
impl UserAuthenticator {
const TOKEN_LEN: usize = 30;
pub fn new(db: Arc<Mutex<SqliteDatabase>>) -> Self {
Self { db }
@ -45,7 +45,7 @@ impl Authenticator {
#[instrument]
pub async fn create_user_token(&mut self, username: &str, password: &Password) -> UserToken {
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;
if let Err(err) = db.save_token(username, &new_token).await {
@ -85,12 +85,12 @@ impl ServerPadlockGenerator {
}
pub struct UserServerKeyGenerator {
user_authenticator: Arc<Authenticator>,
user_authenticator: Arc<UserAuthenticator>,
padlock_generator: Arc<ServerPadlockGenerator>,
}
impl UserServerKeyGenerator {
pub fn new(/* Authenticator, ServerPadlockGenerator? */) -> Self {
pub fn new(/* UserAuthenticator, ServerPadlockGenerator? */) -> Self {
todo!()
}