Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tr/refresh token bug fix - testing on vibi-test #18

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions vibi-dpu/src/bitbucket/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ pub async fn refresh_git_auth(clone_url: &str, directory: &str) -> Option<String
return None;
}
let authinfo = authinfo_opt.expect("empty authinfo_opt in refresh_git_auth");
let mut access_token = authinfo.access_token().to_string();
println!("[refresh_git_auth] Authinfo before update_access_token : {:?}", authinfo.access_token());
let authinfo_opt = update_access_token(&authinfo, clone_url, directory).await;
if authinfo_opt.is_none() {
eprintln!("Empty authinfo_opt from update_access_token");
return None;
}

let latest_authinfo = authinfo_opt.expect("Empty authinfo_opt");
println!("[refresh_git_auth] Authinfo before update_access_token : {:?}", latest_authinfo.access_token());
let access_token = latest_authinfo.access_token().to_string();
return Some(access_token);
}

Expand All @@ -78,7 +80,7 @@ pub async fn update_access_token(auth_info: &AuthInfo,
}
let timestamp = timestamp_opt.expect("Empty timestamp");
let expires_at = timestamp + auth_info.expires_in();
if expires_at > now_secs {
if expires_at < now_secs {
eprintln!("Not yet expired, expires_at = {}, now_secs = {}", expires_at, now_secs);
return Some(auth_info.to_owned());
}
Expand Down