Private
Public Access
1
0

client: actually do authentication properly

This commit is contained in:
2025-05-01 01:02:36 -07:00
parent 59cfc8008b
commit fd4c43d585
7 changed files with 105 additions and 74 deletions

View File

@@ -8,9 +8,6 @@ pub use tokio::sync::Mutex;
use crate::repository::Repository;
use crate::settings::Settings;
pub use kordophone::api::TokenStore;
use kordophone::model::JwtToken;
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!();
@@ -86,19 +83,3 @@ impl DatabaseAccess for Arc<Mutex<Database>> {
database.with_settings(f).await
}
}
static TOKEN_KEY: &str = "token";
#[async_trait]
impl TokenStore for Database {
async fn get_token(&mut self) -> Option<JwtToken> {
self.with_settings(|settings| {
let token: Result<Option<JwtToken>> = settings.get(TOKEN_KEY);
token.unwrap_or_default()
}).await
}
async fn set_token(&mut self, token: JwtToken) {
self.with_settings(|settings| settings.put(TOKEN_KEY, &token).unwrap()).await;
}
}