Skip to content

Commit

Permalink
Unified Return Value
Browse files Browse the repository at this point in the history
  • Loading branch information
Proziam committed Oct 20, 2024
1 parent 90c4c5b commit 7ef0d5c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
14 changes: 12 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ impl AuthClient {
&self,
scope: Option<LogoutScope>,
bearer_token: S,
) -> Result<Response, Error> {
) -> Result<(), Error> {
let mut headers = HeaderMap::new();
headers.insert("apikey", HeaderValue::from_str(&self.api_key)?);
headers.insert(CONTENT_TYPE, HeaderValue::from_str("application/json")?);
Expand All @@ -828,7 +828,17 @@ impl AuthClient {
.send()
.await?;

Ok(response)
let res_status = response.status();
let res_body = response.text().await?;

if res_status.is_success() {
Ok(())
} else {
Err(Error::AuthError {
status: res_status,
message: res_body,
})
}
}

/// Initiates an SSO Login Flow
Expand Down
9 changes: 6 additions & 3 deletions tests/client_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,13 @@ async fn logout_test() {

let logout = auth_client
.logout(Some(LogoutScope::Global), session.access_token)
.await
.unwrap();
.await;

if logout.is_err() {
println!("{:?}", logout)
}

assert!(logout.status().is_success())
assert!(logout.is_ok())
}

#[tokio::test]
Expand Down

0 comments on commit 7ef0d5c

Please sign in to comment.