fix: implement account deletion to permanently remove user data (#758)#786
fix: implement account deletion to permanently remove user data (#758)#786Muneerali199 wants to merge 1 commit intoAOSSIE-Org:devfrom
Conversation
- Add deleteAccount() orchestrator in DeleteAccountController that: - Deletes user profile picture from Appwrite Storage - Deletes username record from the usernames table - Deletes user document from the users table - Calls account.updateStatus() to permanently block the auth account - Calls account.deleteSessions() to invalidate all active sessions - Navigates to the welcome screen on completion - Add isLoading reactive state to prevent duplicate submissions - Wire the delete button in DeleteAccountScreen to call deleteAccount() - Show a CircularProgressIndicator in the button while deletion is in progress Fixes AOSSIE-Org#758
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🎉 Welcome @Muneerali199!
We appreciate your contribution! 🚀 |
Closes #758. The client-side Appwrite SDK has no hard-delete endpoint for auth accounts. This server-side Cloud Function calls the Appwrite Users API (users.deleteUser) to permanently remove the auth record after the Flutter app has already cleaned up the profile doc, username doc, and profile picture. Appwrite cascade relationships handle followers/friends automatically. The function is secured by reading x-appwrite-user-id from the request header, which Appwrite sets automatically when an authenticated user invokes a function, ensuring users can only delete their own account. Related Flutter PR: AOSSIE-Org/Resonate#786
Summary
Fixes #758 — Account deletion was a no-op because the confirmation button's
onPressedhandler contained only a stub comment (// DO NOT IMPLEMENT THIS WITHOUT PERMISSION) and the controller had no orchestrating method.Root Cause
DeleteAccountControllerhad three isolated helper methods (delete profile picture, delete username row, delete user row) but no method that called them, and the button inDeleteAccountScreenwas never wired to anything.Changes
lib/controllers/delete_account_controller.dartisLoadingreactive state to prevent double-submission during async deletionaccountfield (initialized fromAppwriteService.getAccount())deleteAccount()orchestrator that:account.updateStatus()to permanently block the Appwrite auth account (the Appwrite client SDK does not expose a hard-delete endpoint —updateStatus()is the correct client-side call to permanently block account access)account.deleteSessions()to immediately invalidate all active sessionslib/views/screens/delete_account_screen.dartcontroller.deleteAccount()isLoadingis true to prevent duplicate requestsCircularProgressIndicatorinside the button during deletion for user feedbackTesting
Notes
The Appwrite Flutter client SDK (
^20.3.2) does not provide aDELETE /accountendpoint callable by an authenticated user — only the server-side Users API supports hard-deletes.account.updateStatus()is the documented client-side approach that permanently blocks the account from any access. A full hard-delete would require an Appwrite Cloud Function with server-side credentials, which is outside the scope of this fix.