GUI: fix first-run onboarding when no account exists

The dashboard only ever showed a password field, and start_bridge errored
with "No config found" when nothing was configured yet, so a brand-new user
could never get past the start screen. Now the dashboard shows a Tuta email
field too when no account is set up, and start_bridge bootstraps the config
from that email (with defaults) instead of failing. Once an account exists
the email field disappears and only the password is asked (until a keyring
session is saved).
This commit is contained in:
Anthony
2026-06-12 20:17:29 +02:00
parent e3132bb9f5
commit 389a46d91c
4 changed files with 56 additions and 14 deletions
+15 -1
View File
@@ -42,12 +42,26 @@ pub async fn has_saved_session() -> Result<bool, String> {
#[tauri::command]
pub async fn start_bridge(
email: Option<String>,
password: Option<String>,
state: State<'_, BridgeState>,
) -> Result<(), String> {
let mut cfg = match config::load_config() {
Ok(Some(cfg)) if !cfg.email.is_empty() => cfg,
_ => return Err("No config found — save config first".into()),
// First run: no account yet. Bootstrap a default config from the email
// the user just entered on the dashboard, instead of erroring out.
_ => {
let email = email.unwrap_or_default().trim().to_string();
if email.is_empty() {
return Err("Enter your Tuta email to get started".into());
}
let cfg = Config {
email,
..Default::default()
};
config::save_config(&cfg).map_err(|e| format!("Failed to save config: {e}"))?;
cfg
}
};
config::ensure_bridge_password(&mut cfg)