Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting a user throws an error due to the update_user_roles function #11

Open
FranciscoHS19 opened this issue Nov 13, 2023 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@FranciscoHS19
Copy link

FranciscoHS19 commented Nov 13, 2023

Hello!

First of, let me thank you for this great work, it helped immensely in setting up RBAC :)

While developing the user management part of my app I stumbled upon the following error: Deleting a user throws an error due to the update_user_roles function. This happens because I'm cascading the deletion of the user in the group_users table. This, in turn, triggers the update_user_roles function to update the user's roles, but it fails since it can't find the user. I believe a "User exists" check could be added to this function:

SELECT id
INTO _user_check_id
FROM auth.users au
WHERE au.id = _user_id;


IF _user_check_id IS NOT NULL  THEN
@point-source
Copy link
Owner

Oh that's interesting. I've only used soft-deletes for my users so far but I'll test this out and find a fix. Thanks for the report!

@point-source point-source added the bug Something isn't working label Jan 15, 2024
@point-source point-source added the help wanted Extra attention is needed label Jan 23, 2024
@point-source
Copy link
Owner

I'm having a hard time reproducing this. Can you let me know which version of the project you are using and provide a test example? If it's easier, feel free to set up a local supabase copy with migrations and dummy data that can reproduce when deleting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants