Skip to content

Commit

Permalink
quick fix github limit
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Jul 22, 2019
1 parent e97d216 commit 7942c52
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/github/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub struct GitHubUser {

fn id_to_username(
id: web::Path<String>,
gtihub_auth_params: web::Data<String>,
cache: web::Data<Arc<RwLock<TtlCache<String, String>>>>,
) -> impl Future<Item = HttpResponse, Error = Error> {
if let Some(username) = cache.read().ok().and_then(|c| c.get(&*id).cloned()) {
Expand All @@ -74,7 +75,7 @@ fn id_to_username(
let cache_id = (*id).clone();
Either::B(
Client::default()
.get(format!("{}/{}", USER_URL, id))
.get(format!("{}/{}{}", USER_URL, id, *gtihub_auth_params))
.header(http::header::USER_AGENT, "whoami")
.send()
.map_err(Into::into)
Expand Down Expand Up @@ -199,6 +200,10 @@ pub fn github_app<T: AsyncCisClientTrait + 'static>(
let github_client_secret = ClientSecret::new(github.client_secret.clone());
let auth_url = AuthUrl::new(Url::parse(AUTH_URL).expect("Invalid authorization endpoint URL"));
let token_url = TokenUrl::new(Url::parse(TOKEN_URL).expect("Invalid token endpoint URL"));
let gtihub_auth_params = format!(
"?client_id={}&client_secret={}",
&github.client_id, &github.client_secret
);

let client = Arc::new(
BasicClient::new(
Expand Down Expand Up @@ -235,6 +240,7 @@ pub fn github_app<T: AsyncCisClientTrait + 'static>(
.data(client)
.data(cis_client)
.data(ttl_cache)
.data(gtihub_auth_params)
.service(web::resource("/add").route(web::get().to(redirect)))
.service(web::resource("/auth").route(web::get().to_async(auth::<T>)))
.service(web::resource("/username/{id}").route(web::get().to_async(id_to_username)))
Expand Down

0 comments on commit 7942c52

Please sign in to comment.