1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
use dioxus::prelude::*;
use crate::components::modal::Modal;
use crate::state::app_state::AppState;
/// Account deactivation dialog with safety checks.
#[component]
pub fn AccountDeactivationDialog(on_close: EventHandler<()>) -> Element {
let state = use_context::<Signal<AppState>>();
let mut password = use_signal(|| String::new());
let mut erase_data = use_signal(|| false);
let mut confirmed = use_signal(|| false);
let mut deactivating = use_signal(|| false);
let mut error = use_signal(|| Option::<String>::None);
let mut confirm_text = use_signal(|| String::new());
let on_deactivate = move |_| {
if confirm_text.read().as_str() != "DEACTIVATE" {
error.set(Some("Please type DEACTIVATE to confirm".to_string()));
return;
}
if password.read().is_empty() {
error.set(Some("Password is required".to_string()));
return;
}
deactivating.set(true);
error.set(None);
let _pw = password.read().clone();
let erase = *erase_data.read();
spawn(async move {
let client = { state.read().client.clone() };
if let Some(client) = client {
// Use the deactivate account API
use matrix_sdk::ruma::api::client::account::deactivate::v3::Request;
let request = Request::new();
// The actual implementation would include auth with password
match client.send(request).await {
Ok(_) => {
tracing::info!("Account deactivated (erase_data={erase})");
// Log out and clear session
let _ = client.matrix_auth().logout().await;
}
Err(e) => {
error.set(Some(format!("Failed to deactivate: {e}")));
}
}
}
deactivating.set(false);
});
};
rsx! {
Modal {
title: "Deactivate Account".to_string(),
on_close: move |_| on_close.call(()),
div {
class: "account-deactivation",
div {
class: "account-deactivation__warning",
h4 { "⚠ Warning" }
p {
"Deactivating your account is "
strong { "permanent" }
". You will not be able to log in again, and no one will be able to re-register the same user ID."
}
p { "This will:" }
ul {
li { "Leave all rooms and spaces you are in" }
li { "Remove your account from the homeserver" }
li { "Invalidate all your access tokens" }
if *erase_data.read() {
li { "Erase all your messages and data" }
}
}
}
if !*confirmed.read() {
div {
class: "account-deactivation__step",
p { "Are you sure you want to proceed?" }
div {
class: "account-deactivation__actions",
button {
class: "btn btn--secondary",
onclick: move |_| on_close.call(()),
"Cancel"
}
button {
class: "btn btn--danger",
onclick: move |_| confirmed.set(true),
"I understand, continue"
}
}
}
} else {
div {
class: "account-deactivation__step",
label {
class: "settings-toggle",
input {
r#type: "checkbox",
checked: *erase_data.read(),
oninput: move |evt| erase_data.set(evt.checked()),
}
div {
class: "settings-toggle__info",
span { class: "settings-toggle__label", "Erase all messages" }
span { class: "settings-toggle__description",
"Request that the server remove your messages (may not be honored by all servers)"
}
}
}
div {
class: "account-deactivation__field",
label { "Password" }
input {
r#type: "password",
class: "settings-input",
placeholder: "Enter your password",
value: "{password}",
oninput: move |evt| password.set(evt.value()),
}
}
div {
class: "account-deactivation__field",
label { "Type DEACTIVATE to confirm" }
input {
r#type: "text",
class: "settings-input",
placeholder: "DEACTIVATE",
value: "{confirm_text}",
oninput: move |evt| confirm_text.set(evt.value()),
}
}
if let Some(ref err) = *error.read() {
div { class: "account-deactivation__error", "{err}" }
}
div {
class: "account-deactivation__actions",
button {
class: "btn btn--secondary",
onclick: move |_| on_close.call(()),
"Cancel"
}
button {
class: "btn btn--danger",
disabled: *deactivating.read(),
onclick: on_deactivate,
if *deactivating.read() { "Deactivating..." } else { "Deactivate Account" }
}
}
}
}
}
}
}
}