client: actually do authentication properly
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
use kordophone_db::settings::Settings as DbSettings;
|
||||
use anyhow::Result;
|
||||
|
||||
mod keys {
|
||||
pub mod keys {
|
||||
pub static SERVER_URL: &str = "ServerURL";
|
||||
pub static USERNAME: &str = "Username";
|
||||
pub static CREDENTIAL_ITEM: &str = "CredentialItem";
|
||||
pub static TOKEN: &str = "Token";
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -13,6 +14,7 @@ pub struct Settings {
|
||||
pub server_url: Option<String>,
|
||||
pub username: Option<String>,
|
||||
pub credential_item: Option<String>,
|
||||
pub token: Option<String>,
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
@@ -20,11 +22,12 @@ impl Settings {
|
||||
let server_url: Option<String> = db_settings.get(keys::SERVER_URL)?;
|
||||
let username: Option<String> = db_settings.get(keys::USERNAME)?;
|
||||
let credential_item: Option<String> = db_settings.get(keys::CREDENTIAL_ITEM)?;
|
||||
|
||||
let token: Option<String> = db_settings.get(keys::TOKEN)?;
|
||||
Ok(Self {
|
||||
server_url,
|
||||
username,
|
||||
credential_item,
|
||||
token,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -38,6 +41,9 @@ impl Settings {
|
||||
if let Some(credential_item) = &self.credential_item {
|
||||
db_settings.put(keys::CREDENTIAL_ITEM, &credential_item)?;
|
||||
}
|
||||
if let Some(token) = &self.token {
|
||||
db_settings.put(keys::TOKEN, &token)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user