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

Signout fails after user account has been deleted #1518

Open
paule89123 opened this issue Apr 6, 2024 · 0 comments
Open

Signout fails after user account has been deleted #1518

paule89123 opened this issue Apr 6, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@paule89123
Copy link

Describe the bug

supabase.auth.signOut() fails if the user has been deleted. The error is AuthApiError: User from sub claim in JWT does not exist

To Reproduce

See code below (under "Additional context")

Expected behavior

supabase.auth.signOut() should clear the local cache if the user has been deleted.

System information

  • OS: iOS
  • Version of supabase-js: 2.25.0
  • Version of Node.js: 18.19.0

Additional context

My app needs to allow users to delete their accounts. In order to do this, I have created a database function that does the following:

` -- Get the user's ID and email address
SELECT id, email INTO user_id, user_email FROM auth.users WHERE id = auth.uid();

-- Insert a record into the deleted_users table
INSERT INTO public.deleted_users (id, email)
VALUES (user_id, user_email);

-- Delete the user from the auth.users table
DELETE FROM auth.users WHERE id = user_id;`

I call this from the client with:

await supabase.rpc('delete_user')

This successfully deletes the user from auth.users, and deletes their session and refresh token from the db as well. However, the user's session is still cached locally on the client (I'm using React Native/Expo). Thus, I need to log the user out locally. However, calling await supabase.auth.signOut() fails with the error:

AuthApiError: User from sub claim in JWT does not exist

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

No branches or pull requests

1 participant