commit
6e8eb159fa
@ -81,7 +81,9 @@ pub enum NetworkType {
|
|||||||
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
|
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub id: String,
|
pub id: String, // use
|
||||||
|
#[serde(default)]
|
||||||
|
enc_id: String, // store
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
password: String,
|
password: String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@ -301,7 +303,7 @@ impl Config {
|
|||||||
config.password = password;
|
config.password = password;
|
||||||
store |= store1;
|
store |= store1;
|
||||||
let mut id_valid = false;
|
let mut id_valid = false;
|
||||||
let (id, encrypted, store2) = decrypt_str_or_original(&config.id, PASSWORD_ENC_VERSION);
|
let (id, encrypted, store2) = decrypt_str_or_original(&config.enc_id, PASSWORD_ENC_VERSION);
|
||||||
if encrypted {
|
if encrypted {
|
||||||
config.id = id;
|
config.id = id;
|
||||||
id_valid = true;
|
id_valid = true;
|
||||||
@ -312,8 +314,13 @@ impl Config {
|
|||||||
.unwrap_or(crate::get_exe_time())
|
.unwrap_or(crate::get_exe_time())
|
||||||
< crate::get_exe_time()
|
< crate::get_exe_time()
|
||||||
{
|
{
|
||||||
id_valid = true;
|
if !config.id.is_empty()
|
||||||
store = true;
|
&& config.enc_id.is_empty()
|
||||||
|
&& !decrypt_str_or_original(&config.id, PASSWORD_ENC_VERSION).1
|
||||||
|
{
|
||||||
|
id_valid = true;
|
||||||
|
store = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !id_valid {
|
if !id_valid {
|
||||||
@ -336,7 +343,8 @@ impl Config {
|
|||||||
fn store(&self) {
|
fn store(&self) {
|
||||||
let mut config = self.clone();
|
let mut config = self.clone();
|
||||||
config.password = encrypt_str_or_original(&config.password, PASSWORD_ENC_VERSION);
|
config.password = encrypt_str_or_original(&config.password, PASSWORD_ENC_VERSION);
|
||||||
config.id = encrypt_str_or_original(&config.id, PASSWORD_ENC_VERSION);
|
config.enc_id = encrypt_str_or_original(&config.id, PASSWORD_ENC_VERSION);
|
||||||
|
config.id = "".to_owned();
|
||||||
Config::store_(&config, "");
|
Config::store_(&config, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +358,7 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.id.is_empty() || self.key_pair.0.is_empty()
|
(self.id.is_empty() && self.enc_id.is_empty()) || self.key_pair.0.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_home() -> PathBuf {
|
pub fn get_home() -> PathBuf {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user