MCPcopy Index your code
hub / github.com/endbasic/endbasic / logout

Method logout

client/src/cloud.rs:203–223  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

201 }
202
203 async fn logout(&mut self) -> io::Result<()> {
204 let mut auth_data = self.auth_data.borrow_mut();
205 let response = {
206 let auth_data = Self::require_auth_data(auth_data.as_ref())?;
207 self.client
208 .post(self.make_url(&format!("api/users/{}/logout", auth_data.username)))
209 .headers(self.default_headers())
210 .header("Content-Length", 0)
211 .bearer_auth(auth_data.access_token.as_str())
212 .send()
213 .await
214 .map_err(reqwest_error_to_io_error)?
215 };
216 match response.status() {
217 StatusCode::OK => {
218 *auth_data = None;
219 Ok(())
220 }
221 _ => Err(http_response_to_io_error(response).await),
222 }
223 }
224
225 fn is_logged_in(&self) -> bool {
226 self.auth_data.borrow().is_some()

Callers 3

async_execMethod · 0.45
cleanupMethod · 0.45
do_logoutMethod · 0.45

Calls 4

make_urlMethod · 0.80
default_headersMethod · 0.80
as_strMethod · 0.80

Tested by

no test coverage detected