supabase / gotrue-dart

A dart client library for GoTrue.
MIT License
46 stars 37 forks source link

Delete User Account #25

Closed MateusAmin closed 2 years ago

MateusAmin commented 3 years ago

Feature request

await supabase.auth.api.deleteUser(
  '715ed5db-f090-4b8c-a067-640ecee36aa0',
  'YOUR_SERVICE_ROLE_KEY'
)

Is your feature request related to a problem? Please describe.

I would like my users to be able delete their accounts and associated data.

Describe the solution you'd like

https://supabase.io/docs/reference/javascript/delete-user

Describe alternatives you've considered

  1. Deploying Ory Kratos on my K8s cluster.
  2. Dropping the Table from the DB directly.
  3. Making a PR to perform the rest hit.

Additional context

https://github.com/netlify/gotrue/blob/feb3c89564b573e306119a83b918f2e76c91a9a0/api/admin.go#L226-L250 https://github.com/supabase/gotrue-js/blob/master/src/GoTrueApi.ts#L251 https://github.com/supabase/gotrue-dart/blob/main/lib/src/gotrue_api.dart

dshukertjr commented 3 years ago

Hi @MateusAmin!

Thank you for opening this issue! Just to get a bit more context, what is the reason why you need this feature?

It looks like the end point for deleting a user needs service_role or supabase_admin, which means it can only be called from a backend. Are you using Dart as your backend right now?

It looks like the JavaScript library might be separated into two libraries, one for client side and one for server side as discussed here, so I'm thinking maybe it's better to wait for that to happen and if there are folks using Dart on the server side, create something like a supabase-admin-dart library and include this feature there.

Would like to hear what you think @phamhieu .

MateusAmin commented 3 years ago

Hi dshukertjy,

Thanks for following up. We are making an education application and wanted people to be able to remove their accounts. Not super important but we always hate it when we can't delete our own accounts on random sites.

Yeah, we are using Dart as our back-end. Seems like it is speeding up development so far.

Splitting the two libraries seems very ergonomic. I like the idea. Perfectly fine with this not getting merged if that is what you are going for.

dshukertjr commented 3 years ago

Thanks @MateusAmin for your quick reply!

Wow, it's amazing that you are using Dart as your backend! I think it's my first time talking to someone who is doing that! Do you use something like aqueduct.io?

I want to hear what @phamhieu whether to wait for the js library splitting up, or just add this and split the dart library later on, so if you could hold on for now, it would be greatly appreciated! Thank you for your patients.

phamhieu commented 3 years ago

Hi @MateusAmin, It will be faster to send the delete request to gotrue server from your backend api than waiting for a new library.

Let me know if you have any problem doing that. And i'm keen to hear more about your education app.