-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(server-auth): Refactor useReauthenticate to prevent double currentUser calls #10531
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ntUser calls, by calling getCurrentUser to determine if youre logged in
6 tasks
…auth-reauthenticate-refactor * 'main' of github.com:redwoodjs/redwood: chore(canary): Avoid `workspace:*` in published package.json files (#10532)
dthyresson
approved these changes
May 2, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We paired on logic and tried on local Supabse, Approved!
dac09
added a commit
to dac09/redwood
that referenced
this pull request
May 3, 2024
…dwood into feat/supabase-middleware-client * 'feat/supabase-middleware-client' of github.com:dac09/redwood: feat(RSC): Remove `entries.ts` file (redwoodjs#10533) testing to see if getToken is called Try to see if swapping getToken order mock passes Windows CI feat(server-auth): Refactor useReauthenticate to prevent double currentUser calls (redwoodjs#10531) chore(deps): update dependency rollup to v4.17.2 (redwoodjs#10346) fix(deps): update docusaurus monorepo to v3.2.1 (redwoodjs#10371)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…by calling getCurrentUser to determine if youre logged in.
We achieve this by swapping the order in which getUserMetadata and getCurrentUser is called in reauthenticate.
Previously getUserMetadata was a short-hand for checking if the auth SDK think its logged in, however in middleware auth this is an issue because you need to getCurrentUser before getting user metadata in the case of purely cookie based auth like dbAuth (and potentially future ones like firebase, etc.) - since the cookie/token cannot be read on the browser.
We've validated under these scenarios:
☑️ dbAuth legacy (no SSR)
☑️ dbAuth SSR
☑️ supabase legacy
☑️ supabase legacy with
supabase-js
client☑️ supabase legacy with
supbase/ssr
browser client☑️ supabase SSR
Tasks:
update failing tests for auth web clients
🆗 Netlify mocks needed updating, because we check for the presence of access_token in reauthenticate now
🆗 Supertokens mocks needed updating, because
getAccessToken
was not mockedUpdate failing tests in AuthProvider.test.tsx
🆗 All green, had to change how we're testing a little. We no longer try to fetch currentUser and error if we don't have a token, we simply remain "not logged in"