Authenticate on app startup

This commit is contained in:
Piotr Osiewicz 2023-11-23 15:08:21 +01:00
parent b463454062
commit 2a2b3b5e91

View file

@ -8,7 +8,7 @@ use anyhow::{anyhow, Context as _, Result};
use backtrace::Backtrace; use backtrace::Backtrace;
use chrono::Utc; use chrono::Utc;
use cli::FORCE_CLI_MODE_ENV_VAR_NAME; use cli::FORCE_CLI_MODE_ENV_VAR_NAME;
use client::UserStore; use client::{Client, UserStore};
use db::kvp::KEY_VALUE_STORE; use db::kvp::KEY_VALUE_STORE;
use editor::Editor; use editor::Editor;
use fs::RealFs; use fs::RealFs;
@ -249,7 +249,7 @@ fn main() {
} }
} }
let mut _triggered_authentication = false; let mut triggered_authentication = false;
fn open_paths_and_log_errs( fn open_paths_and_log_errs(
paths: &[PathBuf], paths: &[PathBuf],
@ -328,23 +328,23 @@ fn main() {
}) })
.detach(); .detach();
// if !triggered_authentication { if !triggered_authentication {
// cx.spawn(|cx| async move { authenticate(client, &cx).await }) cx.spawn(|cx| async move { authenticate(client, &cx).await })
// .detach_and_log_err(cx); .detach_and_log_err(cx);
// } }
}); });
} }
// async fn authenticate(client: Arc<Client>, cx: &AsyncAppContext) -> Result<()> { async fn authenticate(client: Arc<Client>, cx: &AsyncAppContext) -> Result<()> {
// if stdout_is_a_pty() { if stdout_is_a_pty() {
// if client::IMPERSONATE_LOGIN.is_some() { if client::IMPERSONATE_LOGIN.is_some() {
// client.authenticate_and_connect(false, &cx).await?; client.authenticate_and_connect(false, &cx).await?;
// } }
// } else if client.has_keychain_credentials(&cx) { } else if client.has_keychain_credentials(&cx).await {
// client.authenticate_and_connect(true, &cx).await?; client.authenticate_and_connect(true, &cx).await?;
// } }
// Ok::<_, anyhow::Error>(()) Ok::<_, anyhow::Error>(())
// } }
async fn installation_id() -> Result<(String, bool)> { async fn installation_id() -> Result<(String, bool)> {
let legacy_key_name = "device_id"; let legacy_key_name = "device_id";