diff options
Diffstat (limited to 'crates/turtle/src/atuin_client/settings.rs')
| -rw-r--r-- | crates/turtle/src/atuin_client/settings.rs | 52 |
1 files changed, 7 insertions, 45 deletions
diff --git a/crates/turtle/src/atuin_client/settings.rs b/crates/turtle/src/atuin_client/settings.rs index 5ee7cb77..e8ff98ee 100644 --- a/crates/turtle/src/atuin_client/settings.rs +++ b/crates/turtle/src/atuin_client/settings.rs @@ -1038,7 +1038,7 @@ impl Settings { } pub(crate) async fn should_sync(&self) -> Result<bool> { - if !self.auto_sync || !Self::meta_store().await?.logged_in().await? { + if !self.auto_sync || !self.have_sync_key().await? { return Ok(false); } @@ -1055,52 +1055,14 @@ impl Settings { } } - pub(crate) async fn logged_in(&self) -> Result<bool> { - Self::meta_store().await?.logged_in().await + pub(crate) async fn have_sync_key(&self) -> Result<bool> { + let sa = self.sync_auth().await?; + Ok(matches!(sa, SyncAuth::Legacy { .. })) } - pub(crate) async fn session_token(&self) -> Result<String> { - match Self::meta_store().await?.session_token().await? { - Some(token) => Ok(token), - None => Err(eyre!("Tried to load session; not logged in")), - } - } - - /// Examines the configured sync target and available tokens to determine - /// the correct auth strategy. Also performs cleanup of mis-stored tokens - /// (e.g. a CLI token incorrectly saved in the Hub session slot). - #[cfg(feature = "sync")] - pub(crate) async fn resolve_sync_auth(&self) -> SyncAuth { - let meta = match Self::meta_store().await { - Ok(m) => m, - Err(e) => { - return SyncAuth::NotLoggedIn { - reason: format!("Failed to open meta store: {e}"), - }; - } - }; - - // Self-hosted / legacy server - match meta.session_token().await { - Ok(Some(token)) => SyncAuth::Legacy { token }, - _ => SyncAuth::NotLoggedIn { - reason: "Not logged in. Run 'atuin login' to authenticate \ - with your sync server." - .into(), - }, - } - } - - /// Returns the appropriate auth token for sync operations. - /// - /// Delegates to [`resolve_sync_auth`] and converts the result to an - /// `AuthToken`. Callers that need to distinguish between auth states - /// (e.g. to show different UI) should call `resolve_sync_auth` directly. - #[cfg(feature = "sync")] - pub(crate) async fn sync_auth_token( - &self, - ) -> Result<crate::atuin_client::api_client::AuthToken> { - self.resolve_sync_auth().await.into_auth_token() + pub(crate) async fn sync_auth(&self) -> Result<SyncAuth> { + // TODO(@bpeetz): Add this <2026-06-11> + todo!() } pub(crate) fn default_filter_mode(&self, git_root: bool) -> FilterMode { |
