Implement user-deletion

This commit is contained in:
Mike Schwörer 2025-04-13 16:32:59 +02:00
parent 8c0f0e3e8f
commit 3239a075fb
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 26 additions and 1 deletions

View File

@ -179,6 +179,16 @@ class APIClient {
); );
} }
static Future<User> deleteUser(TokenSource auth, String uid) async {
return await _request(
name: 'deleteUser',
method: 'DELETE',
relURL: 'users/$uid',
fn: User.fromJson,
authToken: auth.getToken(),
);
}
static Future<Client> addClient(TokenSource auth, String fcmToken, String agentModel, String agentVersion, String? name, String clientType) async { static Future<Client> addClient(TokenSource auth, String fcmToken, String agentModel, String agentVersion, String? name, String clientType) async {
return await _request( return await _request(
name: 'addClient', name: 'addClient',

View File

@ -503,7 +503,22 @@ class _AccountRootPageState extends State<AccountRootPage> {
} }
void _deleteAccount() async { void _deleteAccount() async {
// TODO final acc = AppAuth();
if (!acc.isAuth()) return;
try {
await APIClient.deleteUser(acc, acc.userID!);
Toaster.info('Logout', 'Successfully logged out');
acc.clear();
await acc.save();
//TODO clear messages/channels/etc in open views
} catch (exc, trace) {
Toaster.error("Error", 'Failed to delete user');
ApplicationLog.error('Failed to delete user: ' + exc.toString(), trace: trace);
}
} }
void _changeUsername() async { void _changeUsername() async {