diff options
Diffstat (limited to 'src/persist.rs')
-rw-r--r-- | src/persist.rs | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/persist.rs b/src/persist.rs index 762d8b1..2bca386 100644 --- a/src/persist.rs +++ b/src/persist.rs @@ -28,7 +28,7 @@ pub fn get_persist(user: &str) -> bool { } -/// Updates the current sessions persist file +/// Updates a user in the current sessions persist file /// #### Arguments /// * `user` - The user to set persisted pub fn set_persist(user: &str) { @@ -43,8 +43,30 @@ pub fn set_persist(user: &str) { }; match secure::write_file(PERSIST_PATH, &format!("{}", session), &json.to_string()) { Ok(_) => {}, - Err(e) => { - eprintln!("crab: An Internal Has Error: {}", e); + Err(_) => { + eprintln!("crab: An internal error has occured"); + } + }; +} + + +/// Removes a user from the current sessions persist file +/// #### Arguments +/// * `user` - The user to set non-persisted +pub fn remove_persist(user: &str) { + let mut json = match get_persist_config() { + Some(data) => data, + None => return + }; + json[user] = Value::from(0); + let session = match get_current_session() { + Some(data) => data, + None => return + }; + match secure::write_file(PERSIST_PATH, &format!("{}", session), &json.to_string()) { + Ok(_) => {}, + Err(_) => { + eprintln!("crab: An internal error has occured"); } }; } |