mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-25 17:14:57 +02:00
fix(desktop): batch keychain reads to reduce macOS password prompts
Add get_all_secrets command that reads all 18 keys in a single IPC call. This triggers one Keychain prompt instead of 18 on fresh installs.
This commit is contained in:
@@ -113,6 +113,21 @@ fn get_secret(key: String) -> Result<Option<String>, String> {
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn get_all_secrets() -> std::collections::HashMap<String, String> {
|
||||
let mut result = std::collections::HashMap::new();
|
||||
for key in SUPPORTED_SECRET_KEYS.iter() {
|
||||
if let Ok(entry) = Entry::new(KEYRING_SERVICE, key) {
|
||||
if let Ok(value) = entry.get_password() {
|
||||
if !value.trim().is_empty() {
|
||||
result.insert((*key).to_string(), value.trim().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn set_secret(key: String, value: String) -> Result<(), String> {
|
||||
let entry = secret_entry(&key)?;
|
||||
@@ -682,6 +697,7 @@ fn main() {
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
list_supported_secret_keys,
|
||||
get_secret,
|
||||
get_all_secrets,
|
||||
set_secret,
|
||||
delete_secret,
|
||||
get_local_api_token,
|
||||
|
||||
Reference in New Issue
Block a user