mirror of
https://github.com/AppFlowy-IO/AppFlowy
synced 2026-05-05 22:48:27 +00:00
feat: added delete account functionality (#6167)
* feat: added delete account functionality * chore: update client api
This commit is contained in:
parent
f7c6b8792f
commit
a6cce62b06
7 changed files with 49 additions and 14 deletions
25
frontend/rust-lib/Cargo.lock
generated
25
frontend/rust-lib/Cargo.lock
generated
|
|
@ -163,7 +163,7 @@ checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
|
|||
[[package]]
|
||||
name = "app-error"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
|
|
@ -183,7 +183,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "appflowy-ai-client"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
|
|
@ -729,7 +729,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "client-api"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"again",
|
||||
"anyhow",
|
||||
|
|
@ -780,7 +780,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "client-api-entity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"collab-entity",
|
||||
"collab-rt-entity",
|
||||
|
|
@ -793,7 +793,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "client-websocket"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
|
|
@ -1010,7 +1010,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "collab-rt-entity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
|
|
@ -1035,7 +1035,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "collab-rt-protocol"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
|
|
@ -1395,7 +1395,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
|
|||
[[package]]
|
||||
name = "database-entity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"app-error",
|
||||
|
|
@ -2795,7 +2795,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "gotrue"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"futures-util",
|
||||
|
|
@ -2812,7 +2812,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "gotrue-entity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"app-error",
|
||||
|
|
@ -3177,7 +3177,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "infra"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytes",
|
||||
|
|
@ -5377,7 +5377,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "shared-entity"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=52782033948b7d243693ca159ea519d53458c8a6#52782033948b7d243693ca159ea519d53458c8a6"
|
||||
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=14a1382d1c4b77ba16fee3ab867e6bfded85828e#14a1382d1c4b77ba16fee3ab867e6bfded85828e"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"app-error",
|
||||
|
|
@ -5395,6 +5395,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"serde_repr",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ dashmap = "6.0.1"
|
|||
# Run the script.add_workspace_members:
|
||||
# scripts/tool/update_client_api_rev.sh new_rev_id
|
||||
# ⚠️⚠️⚠️️
|
||||
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "52782033948b7d243693ca159ea519d53458c8a6" }
|
||||
client-api-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "52782033948b7d243693ca159ea519d53458c8a6" }
|
||||
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "14a1382d1c4b77ba16fee3ab867e6bfded85828e" }
|
||||
client-api-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "14a1382d1c4b77ba16fee3ab867e6bfded85828e" }
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 0
|
||||
|
|
|
|||
|
|
@ -86,6 +86,12 @@ where
|
|||
Ok(())
|
||||
}
|
||||
|
||||
async fn delete_account(&self) -> Result<(), FlowyError> {
|
||||
let client = self.server.try_get_client()?;
|
||||
client.delete_user().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn generate_sign_in_url_with_email(&self, email: &str) -> Result<String, FlowyError> {
|
||||
let email = email.to_string();
|
||||
let try_get_client = self.server.try_get_client();
|
||||
|
|
|
|||
|
|
@ -133,6 +133,11 @@ pub trait UserCloudService: Send + Sync + 'static {
|
|||
/// Sign out an account
|
||||
async fn sign_out(&self, token: Option<String>) -> Result<(), FlowyError>;
|
||||
|
||||
/// Delete an account and all the data associated with the account
|
||||
async fn delete_account(&self) -> Result<(), FlowyError> {
|
||||
Err(FlowyError::not_support())
|
||||
}
|
||||
|
||||
/// Generate a sign in url for the user with the given email
|
||||
/// Currently, only use the admin client for testing
|
||||
async fn generate_sign_in_url_with_email(&self, email: &str) -> Result<String, FlowyError>;
|
||||
|
|
|
|||
|
|
@ -138,6 +138,15 @@ pub async fn sign_out_handler(manager: AFPluginState<Weak<UserManager>>) -> Resu
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(manager))]
|
||||
pub async fn delete_account_handler(
|
||||
manager: AFPluginState<Weak<UserManager>>,
|
||||
) -> Result<(), FlowyError> {
|
||||
let manager = upgrade_manager(manager)?;
|
||||
manager.delete_account().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(data, manager))]
|
||||
pub async fn update_user_profile_handler(
|
||||
data: AFPluginData<UpdateUserProfilePayloadPB>,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ pub fn init(user_manager: Weak<UserManager>) -> AFPlugin {
|
|||
.event(UserEvent::InitUser, init_user_handler)
|
||||
.event(UserEvent::GetUserProfile, get_user_profile_handler)
|
||||
.event(UserEvent::SignOut, sign_out_handler)
|
||||
.event(UserEvent::DeleteAccount, delete_account_handler)
|
||||
.event(UserEvent::UpdateUserProfile, update_user_profile_handler)
|
||||
.event(UserEvent::SetAppearanceSetting, set_appearance_setting)
|
||||
.event(UserEvent::GetAppearanceSetting, get_appearance_setting)
|
||||
|
|
@ -274,6 +275,9 @@ pub enum UserEvent {
|
|||
|
||||
#[event(input = "SuccessWorkspaceSubscriptionPB")]
|
||||
NotifyDidSwitchPlan = 63,
|
||||
|
||||
#[event()]
|
||||
DeleteAccount = 64,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
|
|
|||
|
|
@ -501,6 +501,16 @@ impl UserManager {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "info", skip(self))]
|
||||
pub async fn delete_account(&self) -> Result<(), FlowyError> {
|
||||
self
|
||||
.cloud_services
|
||||
.get_user_service()?
|
||||
.delete_account()
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Updates the user's profile with the given parameters.
|
||||
///
|
||||
/// This function modifies the user's profile based on the provided update parameters. After updating, it
|
||||
|
|
|
|||
Loading…
Reference in a new issue