From ee5de447d977999e7f5b4b41685d74ce28d63535 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 16 Dec 2019 00:40:30 -0500 Subject: move client id file manipulation out of oauth it doesn't actually have anything to do with the oauth flow --- teleterm/src/oauth.rs | 38 -------------------------------------- 1 file changed, 38 deletions(-) (limited to 'teleterm/src/oauth.rs') diff --git a/teleterm/src/oauth.rs b/teleterm/src/oauth.rs index ee914b4..d76a1b7 100644 --- a/teleterm/src/oauth.rs +++ b/teleterm/src/oauth.rs @@ -1,6 +1,5 @@ use crate::prelude::*; use oauth2::TokenResponse as _; -use std::io::Read as _; mod recurse_center; pub use recurse_center::RecurseCenter; @@ -77,43 +76,6 @@ pub trait Oauth { ) -> Box + Send>; } -pub fn save_client_auth_id( - auth: crate::protocol::AuthType, - id: &str, -) -> impl futures::Future { - let id_file = client_id_file(auth, false).unwrap(); - let id = id.to_string(); - tokio::fs::File::create(id_file.clone()) - .with_context(move || crate::error::CreateFile { - filename: id_file.to_string_lossy().to_string(), - }) - .and_then(|file| { - tokio::io::write_all(file, id).context(crate::error::WriteFile) - }) - .map(|_| ()) -} - -pub fn load_client_auth_id( - auth: crate::protocol::AuthType, -) -> Option { - client_id_file(auth, true).and_then(|id_file| { - std::fs::File::open(id_file).ok().and_then(|mut file| { - let mut id = vec![]; - file.read_to_end(&mut id).ok().map(|_| { - std::string::String::from_utf8_lossy(&id).to_string() - }) - }) - }) -} - -fn client_id_file( - auth: crate::protocol::AuthType, - must_exist: bool, -) -> Option { - let filename = format!("client-oauth-{}", auth.name()); - crate::dirs::Dirs::new().data_file(&filename, must_exist) -} - fn cache_refresh_token( token_cache_file: std::path::PathBuf, token: &oauth2::basic::BasicTokenResponse, -- cgit v1.2.3-54-g00ecf