openfoodfacts / smooth-app

🤳🥫 The new Open Food Facts mobile application for Android and iOS, crafted with Flutter and Dart
https://world.openfoodfacts.org/open-food-facts-mobile-app?utm_source=off&utf_medium=web&utm_campaign=github-repo
Apache License 2.0
835 stars 279 forks source link

Let user remove their account by themselves #4162

Open teolemon opened 1 year ago

teolemon commented 1 year ago

What

Part of

teolemon commented 1 year ago

@M123-dev @monsieurtanuki @g123k this one is really useful, since answering manually to deletion requests is a lot of recurring work

monsieurtanuki commented 1 year ago

@teolemon The thing is that I don't think we have such thing as "check that the user is logged in" in off-dart. That would mean anybody could delete any account. In short, I don't have clear thoughts on that issue, and I'm afraid there are tons of potential blunders here.

teolemon commented 1 year ago

What we could do is change the url of the webview to the deletion page on the website @monsieurtanuki This will make the process truly self service, and going native can be done later

monsieurtanuki commented 1 year ago

@teolemon Currently we go to this page:

    final Uri uri = Uri(
        scheme: 'https',
        host: 'blog.openfoodfacts.org',
        pathSegments: <String>[
          'en',
          'account-deletion',
        ],
        queryParameters: <String, String>{
          'your-subject': subject,
          if (userId != null && userId.isEmail)
            'your-mail': userId
          else if (userId != null)
            'your-name': userId
        });

What should the URL be instead?

teolemon commented 1 year ago

https://world.openfoodfacts.org/cgi/user.pl?type=edit&userid=teolemon (replace teolemon by user-id)

monsieurtanuki commented 1 year ago

I land on an "edit your profile" page, in English, and cannot see a "delete" button.

teolemon commented 1 year ago

@alexgarel @stephanegigandet will deploy that soon I believe. It should be live on .net, but I don't see it with my regular account, as opposed to my superadmin one

monsieurtanuki commented 1 year ago

Ping when it's available on .org.

teolemon commented 1 year ago

@monsieurtanuki it is live

monsieurtanuki commented 1 year ago

@teolemon It's not that easy.

If you're not connected before on the website, you land on an obscure "Error" page https://world.openfoodfacts.org/cgi/user.pl?type=edit&userid=teolemon

If I remove the "type=edit" parameter, I land on a "Register" page (with an improbable pessimistic "Delete account" button) https://world.openfoodfacts.org/cgi/user.pl?userid=monsieurtanuki

Is there a URL to the sign in page?

teolemon commented 1 year ago

https://world.openfoodfacts.org/cgi/session.pl

monsieurtanuki commented 1 year ago

@john-gom Just checking: anybody can call /cgi/user.pl and delete anybody, right?

It would be much safer if you also asked for the password. I mean, in the context you developed (website) it's not very important (already connected), but it is for an API. Correct me if I'm wrong.

teolemon commented 1 year ago
monsieurtanuki commented 1 year ago
  • nope, you can't delete other people @monsieurtanuki :-)

@teolemon I didn't mean that it was a desired feature: my limited knowledge of perl made me ask that while trying to reverse engineer /cgi/user.pl. As I have also a limited experience of curl there's probably something wrong in my syntax, but if I run the following statement I get a localized html page answer like "Permission denied". Perl/curl help needed!

curl
  -X POST https://fr.openfoodfacts.org/cgi/user.pl -H "Content-Type: application/x-www-form-urlencoded"
  -d "userid=test-del-20230703-1&type=edit&action=process&delete=on&password=test-del-20230703-1"
john-gom commented 1 year ago

You won't be able to call the API directly like that. You would need a session cookie for the user before it would work.

monsieurtanuki commented 1 year ago

Then is that possible only for the website or also for flutter? I don't know how it would work.

alexgarel commented 1 year ago

Sorry, it seems we may have to add an API point !

monsieurtanuki commented 1 year ago

@alexgarel It definitely looks so. We need a "password" parameter, in order to prevent someone to delete accidentally - or on purpose - other accounts.

Maybe it's not even enough, as someone could erase all users in bruteforce attack. I don't know how deleting a user works here:

  1. do you send an email and a link to confirm?
  2. do you remove the user or just flag it as "deleted", with a possibility to reactivate?
stephanegigandet commented 1 year ago

Users can only delete their own user account. To work, the request needs to be authenticated: either with a session cookie, or with userid + password.

monsieurtanuki commented 1 year ago

@stephanegigandet That's what I tried unsuccessfully with the code I mentioned earlier:

curl
  -X POST https://fr.openfoodfacts.org/cgi/user.pl -H "Content-Type: application/x-www-form-urlencoded"
  -d "userid=test-del-20230703-1&type=edit&action=process&delete=on&password=test-del-20230703-1"

Is there some typo in my request?

teolemon commented 1 year ago

A test is currently being written

https://github.com/openfoodfacts/openfoodfacts-server/pull/8723/files

teolemon commented 1 year ago

my %delete_form = ( name => 'Test', email => 'bob@test.com', password => '', confirm_password => '', delete => 'on', action => 'process', type => 'edit', userid => 'tests' );

teolemon commented 1 year ago

@monsieurtanuki I've successfully deleted the account in two steps from my browser, login in, and then deleting using the url you tried. It seems you can't do both at the same time. Curious how we do other user management operations

monsieurtanuki commented 1 year ago

@monsieurtanuki I've successfully deleted the account in two steps from my browser, login in, and then deleting using the url you tried. It seems you can't do both at the same time. Curious how we do other user management operations

@teolemon Actually we don't have that much methods in off-dart regarding users:

That said, there's nothing for the moment on the server side that would delete a user in just one command if you're not already connected to the website. Smoothie issue is stalled then.

monsieurtanuki commented 1 year ago

I believe we had this issue specifically for iOS, and we'll soon have the same issue for android:

December 7th, 2023 • User Data policy – Account Deletion requirement ◦ Watch RePlay episode 2 to learn more about the new data deletion policies

M123-dev commented 1 year ago

I've just created https://github.com/openfoodfacts/openfoodfacts-server/issues/8940. Please add any corrections if I am wrong @monsieurtanuki