Get session from file
()
| 130 | |
| 131 | /// Get session from file |
| 132 | pub fn get_session() -> Result<Option<UserSession>, Box<dyn std::error::Error>> { |
| 133 | let path = get_session_file_path(); |
| 134 | if path.exists() { |
| 135 | let json = std::fs::read_to_string(&path)?; |
| 136 | let session: UserSession = serde_json::from_str(&json)?; |
| 137 | println!("Session loaded from file"); |
| 138 | return Ok(Some(session)); |
| 139 | } |
| 140 | Ok(None) |
| 141 | } |
| 142 | |
| 143 | /// Clear session from both keychain and file |
| 144 | pub fn clear_session() -> Result<(), Box<dyn std::error::Error>> { |
no test coverage detected