aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2023-12-08 19:06:12 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2023-12-08 19:06:12 +0100
commit23f918fd0edb224668fb775c770075eb4f44ce4d (patch)
tree7d7a22c144fe57fe7b47f12c99ee6e37aad3cd93 /src/config.rs
parent532c99f3d30ab8adc0963f0814ce3151e1b61caf (diff)
downloadaerogramme-23f918fd0edb224668fb775c770075eb4f44ce4d.tar.gz
aerogramme-23f918fd0edb224668fb775c770075eb4f44ce4d.zip
implement account create
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs
index 876091f..506640f 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1,5 +1,5 @@
use std::collections::HashMap;
-use std::io::Read;
+use std::io::{Read, Write};
use std::net::SocketAddr;
use std::path::PathBuf;
@@ -132,6 +132,18 @@ pub struct UserEntry {
}
#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct SetupEntry {
+ #[serde(default)]
+ pub email_addresses: Vec<String>,
+
+ #[serde(default)]
+ pub clear_password: Option<String>,
+
+ #[serde(flatten)]
+ pub storage: StaticStorage,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(tag = "role")]
pub enum AnyConfig {
Companion(CompanionConfig),
@@ -150,6 +162,16 @@ pub fn read_config<T: serde::de::DeserializeOwned>(config_file: PathBuf) -> Resu
Ok(toml::from_str(&config)?)
}
+pub fn write_config<T: Serialize>(config_file: PathBuf, config: &T) -> Result<()> {
+ let mut file = std::fs::OpenOptions::new()
+ .write(true)
+ .open(config_file.as_path())?;
+
+ file.write_all(toml::to_string(config)?.as_bytes())?;
+
+ Ok(())
+}
+
fn default_mail_attr() -> String {
"mail".into()
}