standardnotes / self-hosted

[Legacy] Self-host your own Standard Notes server for end-to-end encrypted notes and files
https://github.com/standardnotes/server
GNU Affero General Public License v3.0
343 stars 39 forks source link

Account deletion on self-hosted instance #75

Open TheEgghead27 opened 2 years ago

TheEgghead27 commented 2 years ago

Service Versions (please complete the following information): Paste the output of ./server.sh version. For example:

 Container                             Repository                        Tag                 Image Id            Size
api-gateway-standalone                standardnotes/api-gateway         1.40.1              614ea1d3f64c        851MB
auth-standalone                       standardnotes/auth                1.46.2              6648d9486d27        928MB
auth-worker-standalone                standardnotes/auth                1.46.2              6648d9486d27        928MB
cache-standalone                      redis                             6.0-alpine          09401fed2a42        24.7MB
db-standalone                         mysql                             5.6                 dd3b2a5dcb48        303MB
files-standalone                      standardnotes/files               1.9.0               baa6121a09d1        1.05GB
syncing-server-js-standalone          standardnotes/syncing-server-js   1.54.1              2455980ced7d        973MB
syncing-server-js-worker-standalone   standardnotes/syncing-server-js   1.54.1              2455980ced7d        973MB

Describe the issue Hello, I had accidentally registered an account on my self-hosted instance with a typo in the account's email, and I was wondering what the proper way to delete said account would be, since the Standard Notes client does not offer this, and the official Standard Notes instance uses its own separate page for account deletion. Is there an API endpoint or SQL command to completely delete an account's data, and if so, would it be possible for it to be documented?

moughxyz commented 2 years ago

There's no single public API/SQL command afaik. For now best option would be to use an SQL client to delete the entries.

jackyzy823 commented 1 year ago

Note: use this under your own risk.

Steps:

  1. backup your data first! docker-compose exec db sh -c 'MYSQL_PWD=$MYSQL_ROOT_PASSWORD mysqldump $MYSQL_DATABASE' -- > backup.sql
  2. spawn a mysql shell via docker-compose exec db sh -c 'MYSQL_PWD=$MYSQL_ROOT_PASSWORD mysql $MYSQL_DATABASE'.
  3. (Optionally) If you created subscription.
    DELETE FROM user_roles WHERE user_uuid = (SELECT uuid FROM users WHERE email="<YOUR_EMAIL>");
    DELETE FROM user_subscriptions WHERE user_uuid = (SELECT uuid FROM users WHERE email="<YOUR_EMAIL>");
  4. (Optionally) Delete Note History(revisions) if exists
    DELETE FROM revisions WHERE item_uuid IN ( SELECT uuid FROM  items WHERE user_uuid =  (SELECT uuid FROM users WHERE email= "<YOUR_EMAIL>") );
  5. Delete Notes
    DELETE FROM items WHERE user_uuid =  (SELECT uuid FROM users WHERE email= "<YOUR_EMAIL>");
  6. Delete Login Sessions
    DELETE FROM sessions WHERE user_uuid =  (SELECT uuid FROM users WHERE email= "<YOUR_EMAIL>");
  7. Final Step. Delete User
    DELETE FROM users WHERE email= "<YOUR_EMAIL>";
kzshantonu commented 1 year ago

+1 this should work with the native 'delete account' button in client apps