diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-10-16 10:11:34 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-10-16 10:11:34 -0400 |
commit | 4eb33b05783a961a8bed262dc7b5cd7f79a13194 (patch) | |
tree | 27f1bea341fd447aecfc2a50b8c89e6836dc9a48 | |
parent | 96bc0dccef3db801759bc45468044d93272c27d1 (diff) | |
download | teleterm-4eb33b05783a961a8bed262dc7b5cd7f79a13194.tar.gz teleterm-4eb33b05783a961a8bed262dc7b5cd7f79a13194.zip |
simplify
-rw-r--r-- | src/oauth/recurse_center.rs | 35 | ||||
-rw-r--r-- | src/server.rs | 8 |
2 files changed, 21 insertions, 22 deletions
diff --git a/src/oauth/recurse_center.rs b/src/oauth/recurse_center.rs index 1bd6de7..5a9b2b4 100644 --- a/src/oauth/recurse_center.rs +++ b/src/oauth/recurse_center.rs @@ -6,7 +6,24 @@ pub struct Oauth { } impl Oauth { - pub fn new(config: super::Config, user_id: &str) -> Self { + pub fn new( + client_id: &str, + client_secret: &str, + redirect_url: url::Url, + user_id: &str, + ) -> Self { + let config = super::Config { + client_id: client_id.to_string(), + client_secret: client_secret.to_string(), + auth_url: url::Url::parse( + "https://www.recurse.com/oauth/authorize", + ) + .unwrap(), + token_url: url::Url::parse("https://www.recurse.com/oauth/token") + .unwrap(), + redirect_url, + }; + Self { client: config.into_basic_client(), user_id: user_id.to_string(), @@ -43,22 +60,6 @@ impl super::Oauth for Oauth { } } -pub fn config( - client_id: &str, - client_secret: &str, - redirect_url: url::Url, -) -> super::Config { - super::Config { - client_id: client_id.to_string(), - client_secret: client_secret.to_string(), - auth_url: url::Url::parse("https://www.recurse.com/oauth/authorize") - .unwrap(), - token_url: url::Url::parse("https://www.recurse.com/oauth/token") - .unwrap(), - redirect_url, - } -} - #[derive(serde::Deserialize)] struct User { name: String, diff --git a/src/server.rs b/src/server.rs index 90728dd..e267024 100644 --- a/src/server.rs +++ b/src/server.rs @@ -407,11 +407,9 @@ impl<S: tokio::io::AsyncRead + tokio::io::AsyncWrite + Send + 'static> id.is_some(), Box::new( crate::oauth::recurse_center::Oauth::new( - crate::oauth::recurse_center::config( - &client_id, - &client_secret, - redirect_url, - ), + &client_id, + &client_secret, + redirect_url, &id.clone().unwrap_or_else(|| { format!("{}", uuid::Uuid::new_v4()) }), |