mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 18:41:10 +00:00
Authenticate on startup if ZED_IMPERSONATE is assigned
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
657b92b020
commit
4a42025c28
2 changed files with 9 additions and 3 deletions
|
@ -45,7 +45,7 @@ pub use user::*;
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref ZED_SERVER_URL: String =
|
static ref ZED_SERVER_URL: String =
|
||||||
std::env::var("ZED_SERVER_URL").unwrap_or("https://zed.dev".to_string());
|
std::env::var("ZED_SERVER_URL").unwrap_or("https://zed.dev".to_string());
|
||||||
static ref IMPERSONATE_LOGIN: Option<String> = std::env::var("ZED_IMPERSONATE")
|
pub static ref IMPERSONATE_LOGIN: Option<String> = std::env::var("ZED_IMPERSONATE")
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|s| if s.is_empty() { None } else { Some(s) });
|
.and_then(|s| if s.is_empty() { None } else { Some(s) });
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,14 @@ fn main() {
|
||||||
cx.spawn({
|
cx.spawn({
|
||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
|cx| async move {
|
|cx| async move {
|
||||||
if !stdout_is_a_pty() && client.has_keychain_credentials(&cx) {
|
if stdout_is_a_pty() {
|
||||||
client.authenticate_and_connect(true, &cx).await?;
|
if client::IMPERSONATE_LOGIN.is_some() {
|
||||||
|
client.authenticate_and_connect(false, &cx).await?;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if client.has_keychain_credentials(&cx) {
|
||||||
|
client.authenticate_and_connect(true, &cx).await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok::<_, anyhow::Error>(())
|
Ok::<_, anyhow::Error>(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue