Auth0 Home Blog Docs

Rules that run before user deletion


I wonder if there is a way to run rules on user deletion? If not, is there another way to hook into user deletion? In our system we need to make a pre check before a user is deleted.

Thank you

Hey there @flle!

Basically the core thing regarding rules that you need to take into account is that they are run upon successful login.

So there is no way to hook into account deletion?

Can you provide me with more context around what you want to do before deleting the user? What kind of pre-check is that?

Sure. Our users can own “Companies” in our software. The user should only be able to delete his account IF he’s not the only owner of the company. It would be good if our application could set a flag in the users app metadata that the user can be deleted. Users can delete them self if that flag is set to true (so before an account is deleted we would need to check if the user can be deleted). I personally would like to avoid having an access token on our backend that can delete users. So one solution would be what I described. Our application needs to allow it, and the user can then his account since the application gave approval. The users access token would need to have the delete account scope as well (don’t know if that’s the correct name of the scope - but I guess there is something like that).