|
@@ -1,9 +1,9 @@
|
|
use crate::{
|
|
use crate::{
|
|
entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UserDetail},
|
|
entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UserDetail},
|
|
- errors::{ErrorBuilder, ErrorCode, UserError},
|
|
|
|
|
|
+ errors::UserError,
|
|
};
|
|
};
|
|
|
|
|
|
-use crate::entities::{UpdateUserParams, UserToken};
|
|
|
|
|
|
+use crate::entities::UpdateUserParams;
|
|
use flowy_infra::future::ResultFuture;
|
|
use flowy_infra::future::ResultFuture;
|
|
use flowy_net::{config::*, request::HttpRequestBuilder};
|
|
use flowy_net::{config::*, request::HttpRequestBuilder};
|
|
use std::sync::Arc;
|
|
use std::sync::Arc;
|
|
@@ -14,7 +14,7 @@ pub trait UserServerAPI {
|
|
fn sign_up(&self, params: SignUpParams) -> ResultFuture<SignUpResponse, UserError>;
|
|
fn sign_up(&self, params: SignUpParams) -> ResultFuture<SignUpResponse, UserError>;
|
|
fn sign_in(&self, params: SignInParams) -> ResultFuture<SignInResponse, UserError>;
|
|
fn sign_in(&self, params: SignInParams) -> ResultFuture<SignInResponse, UserError>;
|
|
fn sign_out(&self, token: &str) -> ResultFuture<(), UserError>;
|
|
fn sign_out(&self, token: &str) -> ResultFuture<(), UserError>;
|
|
- fn update_user(&self, params: UpdateUserParams) -> ResultFuture<(), UserError>;
|
|
|
|
|
|
+ fn update_user(&self, token: &str, params: UpdateUserParams) -> ResultFuture<(), UserError>;
|
|
fn get_user_detail(&self, token: &str) -> ResultFuture<UserDetail, UserError>;
|
|
fn get_user_detail(&self, token: &str) -> ResultFuture<UserDetail, UserError>;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -33,22 +33,23 @@ impl UserServerAPI for UserServer {
|
|
}
|
|
}
|
|
|
|
|
|
fn sign_out(&self, token: &str) -> ResultFuture<(), UserError> {
|
|
fn sign_out(&self, token: &str) -> ResultFuture<(), UserError> {
|
|
- let params = UserToken {
|
|
|
|
- token: token.to_string(),
|
|
|
|
- };
|
|
|
|
|
|
+ let token = token.to_owned();
|
|
ResultFuture::new(async move {
|
|
ResultFuture::new(async move {
|
|
- let _ = user_sign_out(params, SIGN_OUT_URL.as_ref()).await;
|
|
|
|
|
|
+ let _ = user_sign_out(&token, SIGN_OUT_URL.as_ref()).await;
|
|
Ok(())
|
|
Ok(())
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
- fn update_user(&self, params: UpdateUserParams) -> ResultFuture<(), UserError> {
|
|
|
|
- unimplemented!();
|
|
|
|
|
|
+ fn update_user(&self, token: &str, params: UpdateUserParams) -> ResultFuture<(), UserError> {
|
|
|
|
+ let token = token.to_owned();
|
|
|
|
+ ResultFuture::new(async move {
|
|
|
|
+ update_user_detail(&token, params, USER_PROFILE_URL.as_ref()).await
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
fn get_user_detail(&self, token: &str) -> ResultFuture<UserDetail, UserError> {
|
|
fn get_user_detail(&self, token: &str) -> ResultFuture<UserDetail, UserError> {
|
|
let token = token.to_owned();
|
|
let token = token.to_owned();
|
|
- ResultFuture::new(async move { get_user_detail(&token, USER_DETAIL_URL.as_ref()).await })
|
|
|
|
|
|
+ ResultFuture::new(async move { get_user_detail(&token, USER_PROFILE_URL.as_ref()).await })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -72,9 +73,9 @@ pub async fn user_sign_in(params: SignInParams, url: &str) -> Result<SignInRespo
|
|
Ok(response)
|
|
Ok(response)
|
|
}
|
|
}
|
|
|
|
|
|
-pub async fn user_sign_out(params: UserToken, url: &str) -> Result<(), UserError> {
|
|
|
|
|
|
+pub async fn user_sign_out(token: &str, url: &str) -> Result<(), UserError> {
|
|
let _ = HttpRequestBuilder::delete(&url.to_owned())
|
|
let _ = HttpRequestBuilder::delete(&url.to_owned())
|
|
- .protobuf(params)?
|
|
|
|
|
|
+ .header(HEADER_TOKEN, token)
|
|
.send()
|
|
.send()
|
|
.await?;
|
|
.await?;
|
|
Ok(())
|
|
Ok(())
|