(&mut self)
| 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() |
no test coverage detected