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

fix(auth): sign out regardless of request success #375

Merged
merged 2 commits into from
May 10, 2024

Conversation

leoMehlig
Copy link
Contributor

This lets the client reset the session, which is relevant if a logout fails (for example if the user is offline).

@leoMehlig leoMehlig requested a review from grdsdev as a code owner May 9, 2024 11:29
@grdsdev
Copy link
Collaborator

grdsdev commented May 9, 2024

@leoMehlig if I understand this is used to fix an issue with the signOut not working when offline.

Looking at the flutter implementation again https://github.com/supabase/supabase-flutter/blob/main/packages/gotrue/lib/src/gotrue_client.dart#L844 it resets the session before making the request, so it will sign out regardless of the request succeeding or not. I think this is the way to go here.

Now that we have the currentSession without validating the session, it should be easy to implement the same behavior as the Flutter lib.

Let me know if you want to do it in this PR, or I should PR this changes I mentioned.

@leoMehlig
Copy link
Contributor Author

Good point @grdsdev! I've adjusted the PR to do this and removed the resetSession function.

I had to use the execute instead of the authorizedExecute function and manually add the auth header. I think this is fine, but we could also refactor the authorizedExecute to allow passing in an accessToken.

Sources/Auth/AuthClient.swift Outdated Show resolved Hide resolved
@grdsdev grdsdev changed the title Adds resetSession funtion fix(auth): sign out regardless of request success May 10, 2024
@grdsdev grdsdev merged commit 25178e2 into supabase:main May 10, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants