mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
fix loading authcookie into cookie store on ssh (#2226)
This commit is contained in:
@@ -54,7 +54,8 @@ impl Drop for CliContextSeed {
|
|||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let store = self.cookie_store.lock().unwrap();
|
let mut store = self.cookie_store.lock().unwrap();
|
||||||
|
store.remove("localhost", "", "local");
|
||||||
store.save_json(&mut *writer).unwrap();
|
store.save_json(&mut *writer).unwrap();
|
||||||
writer.sync_all().unwrap();
|
writer.sync_all().unwrap();
|
||||||
std::fs::rename(tmp, &self.cookie_path).unwrap();
|
std::fs::rename(tmp, &self.cookie_path).unwrap();
|
||||||
@@ -101,19 +102,22 @@ impl CliContext {
|
|||||||
.unwrap_or(Path::new("/"))
|
.unwrap_or(Path::new("/"))
|
||||||
.join(".cookies.json")
|
.join(".cookies.json")
|
||||||
});
|
});
|
||||||
let cookie_store = Arc::new(CookieStoreMutex::new(if cookie_path.exists() {
|
let cookie_store = Arc::new(CookieStoreMutex::new({
|
||||||
let mut store = CookieStore::load_json(BufReader::new(File::open(&cookie_path)?))
|
let mut store = if cookie_path.exists() {
|
||||||
.map_err(|e| eyre!("{}", e))
|
CookieStore::load_json(BufReader::new(File::open(&cookie_path)?))
|
||||||
.with_kind(crate::ErrorKind::Deserialization)?;
|
.map_err(|e| eyre!("{}", e))
|
||||||
|
.with_kind(crate::ErrorKind::Deserialization)?
|
||||||
|
} else {
|
||||||
|
CookieStore::default()
|
||||||
|
};
|
||||||
if let Ok(local) = std::fs::read_to_string(LOCAL_AUTH_COOKIE_PATH) {
|
if let Ok(local) = std::fs::read_to_string(LOCAL_AUTH_COOKIE_PATH) {
|
||||||
store
|
store
|
||||||
.insert_raw(&Cookie::new("local", local), &"http://localhost".parse()?)
|
.insert_raw(&Cookie::new("local", local), &"http://localhost".parse()?)
|
||||||
.with_kind(crate::ErrorKind::Network)?;
|
.with_kind(crate::ErrorKind::Network)?;
|
||||||
}
|
}
|
||||||
store
|
store
|
||||||
} else {
|
|
||||||
CookieStore::default()
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Ok(CliContext(Arc::new(CliContextSeed {
|
Ok(CliContext(Arc::new(CliContextSeed {
|
||||||
base_url: url.clone(),
|
base_url: url.clone(),
|
||||||
rpc_url: {
|
rpc_url: {
|
||||||
|
|||||||
Reference in New Issue
Block a user