Skip to content

Commit

Permalink
adjustment against the new changes in server side.
Browse files Browse the repository at this point in the history
  • Loading branch information
youngsofun committed Nov 7, 2024
1 parent 5ddb17b commit 8ee811b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
13 changes: 3 additions & 10 deletions core/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::auth::{AccessTokenAuth, AccessTokenFileAuth, Auth, BasicAuth};
use crate::error_code::{need_refresh_token, ResponseWithErrorCode};
use crate::global_cookie_store::GlobalCookieStore;
use crate::login::{
LoginRequest, LoginResponseResult, LogoutRequest, RefreshResponse, RefreshSessionTokenRequest,
LoginRequest, LoginResponseResult, RefreshResponse, RefreshSessionTokenRequest,
SessionTokenInfo,
};
use crate::presign::{presign_upload_to_stage, PresignMode, PresignedResponse, Reader};
Expand Down Expand Up @@ -648,9 +648,9 @@ impl APIClient {
LoginResponseResult::Err { error } => return Err(Error::AuthFailure(error)),
LoginResponseResult::Ok(info) => {
self.server_version = Some(info.version.clone());
if !info.token_info.session_token.is_empty() {
if let Some(tokens) = info.tokens {
self.session_token_info = Some(Arc::new(parking_lot::Mutex::new((
info.token_info,
tokens,
Instant::now(),
))))
}
Expand All @@ -663,12 +663,6 @@ impl APIClient {
let endpoint = self.endpoint.join("/v1/session/logout")?;

let session_state = self.session_state();
let refresh_token = self
.session_token_info
.as_ref()
.map(|info| info.lock().0.refresh_token.clone());
let body = LogoutRequest { refresh_token };

let need_sticky = session_state.need_sticky.unwrap_or(false);
let mut headers = self.make_headers(None)?;
if need_sticky {
Expand All @@ -679,7 +673,6 @@ impl APIClient {
let builder = self
.cli
.post(endpoint.clone())
.json(&body)
.headers(headers.clone());

let builder = self.wrap_auth_or_session_token(builder)?;
Expand Down
8 changes: 1 addition & 7 deletions core/src/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ pub struct SessionTokenInfo {
#[derive(Deserialize, Debug, Clone)]
pub struct LoginResponse {
pub version: String,
#[serde(flatten)]
pub token_info: SessionTokenInfo,
pub tokens: Option<SessionTokenInfo>,
}
#[derive(Deserialize, Debug)]
#[serde(untagged)]
Expand All @@ -74,8 +73,3 @@ pub enum RefreshResponse {
Ok(SessionTokenInfo),
Err { error: ErrorCode },
}

#[derive(Serialize, Debug)]
pub struct LogoutRequest {
pub refresh_token: Option<String>,
}

0 comments on commit 8ee811b

Please sign in to comment.