client: actually do authentication properly
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user