diff --git a/src-tauri/src/git.rs b/src-tauri/src/git.rs index 57af1a1..3b76c3f 100644 --- a/src-tauri/src/git.rs +++ b/src-tauri/src/git.rs @@ -2432,8 +2432,6 @@ const CRED_SERVICE: &str = "tauri_git_lite"; pub struct StoredCredential { pub username: String, pub password: String, - #[serde(default, rename = "expiresAt", skip_serializing_if = "Option::is_none")] - pub expires_at: Option, } fn cred_entry(key: &str) -> Result { @@ -2616,19 +2614,9 @@ pub fn cred_load(key: String) -> Result, String> { } #[tauri::command(async)] -pub fn cred_save( - key: String, - username: String, - password: String, - expires_at: Option, -) -> Result<(), String> { +pub fn cred_save(key: String, username: String, password: String) -> Result<(), String> { let entry = cred_entry(&key)?; - let expires_at = expires_at.filter(|value| !value.trim().is_empty()); - let cred = StoredCredential { - username, - password, - expires_at, - }; + let cred = StoredCredential { username, password }; let json = serde_json::to_string(&cred) .map_err(|err| format!("Could not serialize credentials: {err}"))?; entry diff --git a/src/App.svelte b/src/App.svelte index 0984204..8e25b87 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -180,7 +180,6 @@ import { orgKeyFromUrl, - isCredentialExpired, isAuthError, stripAuthPrefix, summarizeGitError, @@ -2219,11 +2218,10 @@ if (!username && !password) { const stored = await loadStoredCredential(credentialKey); - if (stored && !isCredentialExpired(stored)) { + if (stored) { await cloneRepo(remoteUrl, parentPath, directoryName, stored.username, stored.password, credentialKey, true); return; } - if (stored && credentialKey) await credDelete(credentialKey).catch(() => {}); } operation = "Cloning repository"; @@ -2921,7 +2919,7 @@ if (!activeRepoPath || isBusy) return; const key = await currentCredKey(); const stored = await loadStoredCredential(key); - const credential = stored && !isCredentialExpired(stored) ? stored : null; + const credential = stored ?? null; await runOperation(`Pushing tag ${tag.name}`, async () => { try { @@ -3028,12 +3026,7 @@ async function storedCredentialForNoteRemote(remote: string, direction: "fetch" | "push") { const config = commitNoteRemotes.find((item) => item.name === remote); const key = orgKeyFromUrl(direction === "push" ? (config?.push_url ?? "") : (config?.fetch_url ?? "")); - const stored = await loadStoredCredential(key); - if (stored && isCredentialExpired(stored)) { - if (key) await credDelete(key).catch(() => {}); - return null; - } - return stored; + return loadStoredCredential(key); } function commitNoteRemoteError(error: unknown): string { @@ -3271,12 +3264,7 @@ handleRemoteResult("push", key, fromStore); } - async function handleCredentialSubmit( - username: string, - password: string, - save: boolean, - expiresAt: string | null, - ) { + async function handleCredentialSubmit(username: string, password: string, save: boolean) { const key = credDialogKey; if (credDialogAction === "pull") await doActualPull(username, password, key, false); else if (credDialogAction === "push") await doActualPush(username, password, key, false); @@ -3296,7 +3284,7 @@ // Only persist once the operation actually succeeded (dialog has closed). if (!credDialogOpen && save && key) { try { - await credSave(key, username, password, expiresAt); + await credSave(key, username, password); } catch (error) { errorMessage = errorToMessage(error); } @@ -3311,15 +3299,13 @@ const key = await currentCredKey(); const stored = await loadStoredCredential(key); - if (stored && !isCredentialExpired(stored)) { + if (stored) { if (action === "pull") await doActualPull(stored.username, stored.password, key, true); else if (action === "fetch") await doActualFetch(stored.username, stored.password, key, true); else await doActualPush(stored.username, stored.password, key, true); return; } - // Expired entry → clean it up before prompting again. - if (stored && key) await credDelete(key).catch(() => {}); await openCredentialDialog(action, key); } diff --git a/src/lib/components/AiSettingsDialog.svelte b/src/lib/components/AiSettingsDialog.svelte index 2673330..35b5e7c 100644 --- a/src/lib/components/AiSettingsDialog.svelte +++ b/src/lib/components/AiSettingsDialog.svelte @@ -85,7 +85,7 @@ const key = CRED_KEYS[target]; const trimmed = value.trim(); if (trimmed) { - await credSave(key, "api-key", trimmed, null); + await credSave(key, "api-key", trimmed); } else { await credDelete(key); } diff --git a/src/lib/components/CredentialDialog.svelte b/src/lib/components/CredentialDialog.svelte index f44a42e..893d413 100644 --- a/src/lib/components/CredentialDialog.svelte +++ b/src/lib/components/CredentialDialog.svelte @@ -17,7 +17,7 @@ action: "push" | "pull" | "fetch" | "clone"; error: string; isBusy: boolean; - onSubmit: (username: string, password: string, save: boolean, expiresAt: string | null) => void; + onSubmit: (username: string, password: string, save: boolean) => void; onCancel: () => void; } @@ -36,7 +36,6 @@ let password = $state(""); let showPassword = $state(false); let saveSession = $state(true); - let expiresAt = $state(""); let canSubmit = $derived( !isBusy && @@ -62,12 +61,7 @@ function handleSubmit(e: SubmitEvent) { e.preventDefault(); if (!canSubmit) return; - onSubmit( - mode === "token" ? "oauth2" : username, - password, - saveSession, - saveSession && expiresAt ? expiresAt : null, - ); + onSubmit(mode === "token" ? "oauth2" : username, password, saveSession); } @@ -191,19 +185,6 @@ {/if} - {#if saveSession} -
- - - After this date you'll automatically be asked to log in again. -
- {/if} -