| 75 | } |
| 76 | |
| 77 | pub async fn load_from_file(data_dir: &Path) -> Self { |
| 78 | let filepath = data_dir.join("auth.json"); |
| 79 | let manager = Self::with_filepath(filepath.clone()); |
| 80 | if let Ok(content) = tokio::fs::read_to_string(&filepath).await { |
| 81 | if let Ok(data) = serde_json::from_str::<HashMap<String, AuthInfo>>(&content) { |
| 82 | let mut creds = manager.credentials.write().await; |
| 83 | *creds = data; |
| 84 | } |
| 85 | } |
| 86 | manager |
| 87 | } |
| 88 | |
| 89 | pub async fn get(&self, provider_id: &str) -> Option<AuthInfo> { |
| 90 | let creds = self.credentials.read().await; |