client: Add CloudUserStore (#35370)

This PR adds a new `CloudUserStore` for storing information about the
user retrieved from Cloud instead of Collab.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-07-30 18:43:10 -04:00 committed by GitHub
parent 289f420504
commit bb1a7ccbba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 68 additions and 4 deletions

View file

@ -24,6 +24,10 @@ impl CloudApiClient {
}
}
pub fn has_credentials(&self) -> bool {
self.credentials.read().is_some()
}
pub fn set_credentials(&self, user_id: u32, access_token: String) {
*self.credentials.write() = Some(Credentials {
user_id,
@ -43,7 +47,7 @@ impl CloudApiClient {
))
}
pub async fn get_authenticated_user(&self) -> Result<AuthenticatedUser> {
pub async fn get_authenticated_user(&self) -> Result<GetAuthenticatedUserResponse> {
let request = Request::builder()
.method(Method::GET)
.uri(
@ -69,8 +73,7 @@ impl CloudApiClient {
let mut body = String::new();
response.body_mut().read_to_string(&mut body).await?;
let response: GetAuthenticatedUserResponse = serde_json::from_str(&body)?;
Ok(response.user)
Ok(serde_json::from_str(&body)?)
}
}