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(clerk auth): set auth state to loading while reauthenticating #7852

Merged
merged 7 commits into from
Apr 1, 2023

Conversation

jtoar
Copy link
Contributor

@jtoar jtoar commented Mar 17, 2023

Context: https://community.redwoodjs.com/t/clerk-the-signup-and-signin-components-cannot-render-when-a-user-is-already-signed-in-unless-the-application-allows-multiple-sessions-since-a-user-is-signed-in-and-this-application-only-allows-a-single-session/4694/5.

This is to solve another mismatch in auth state between Redwood's auth provider and Clerk. We know if the user is logged in and auth has loaded before we know the exact details of the current user, so we can update the state to reflect this earlier and avoid the router hanging on to old state.

we know if the user is logged in and auth has loaded before we know the
exact details of the current user, so we can update the state to reflect this
earlier
@jtoar jtoar added the release:fix This PR is a fix label Mar 17, 2023
@replay-io
Copy link

replay-io bot commented Mar 17, 2023

16 replays were recorded for 221a0ec.

image 0 Failed
image 16 Passed
    requireAuth graphql checks
          ```
          locator.waitFor: Target closed
          =========================== logs ===========================
          waiting for locator('.rw-form-error-title').locator('text=You don\'t have permission to do that') to be visible
          ============================================================
          ```
        </ol>
      </details>
      <li><a href=https://app.replay.io/recording/3496b876-693b-4643-b50f-91b73cab3df6>useAuth hook, auth redirects checks</a></li>
      <li><a href=https://app.replay.io/recording/569243a3-bd7f-4b9e-9dea-e54ee220b179>Check that a specific blog post is prerendered</a></li>
      <li><a href=https://app.replay.io/recording/e95aaea5-4349-40a4-9e7f-7a2d629c9e69>Check that about is prerendered</a></li>
      <li><a href=https://app.replay.io/recording/4709107e-f158-409b-8c89-713e363a270e>Check that homepage is prerendered</a></li>
      <li><a href=https://app.replay.io/recording/2c505e22-3e1e-487e-80fc-dacf1b5f40e4>Check that meta-tags are rendering the correct dynamic data</a></li>
      <li><a href=https://app.replay.io/recording/e58fe087-4c8d-4946-8ee8-d59f72804149>Check that you can navigate from home page to specific blog post</a></li>
      <li><a href=https://app.replay.io/recording/fa6fcc7d-af68-4dcc-80f9-6e67f5e34cf5>Waterfall prerendering (nested cells)</a></li>
      <li><a href=https://app.replay.io/recording/bb95c884-087d-4643-bc45-7117f34d722d>RBAC: Admin user should be able to delete contacts</a></li>
      <li><a href=https://app.replay.io/recording/300597af-2c19-4f30-8312-f537d581dbf6>RBAC: Should not be able to delete contact as non-admin user</a></li>
      <li><a href=https://app.replay.io/recording/84e5095e-fbd9-4e65-b8cc-29fd5ec7a7e7>Smoke test with dev server</a></li>
      <li><a href=https://app.replay.io/recording/44b9430d-8833-463e-87a4-58844bc6da9a>Smoke test with rw serve</a></li>
      <li><a href=https://app.replay.io/recording/a536a8fc-f45b-4d2f-be95-bc892cb0279e>Loads Cell mocks when Cell is nested in another story</a></li>
      <li><a href=https://app.replay.io/recording/ad7b0047-3c05-468d-932c-e68d3944a55a>Loads Cell Stories</a></li>
      <li><a href=https://app.replay.io/recording/6b8aa710-cca6-4d37-b550-0406814f36d2>Loads MDX Stories</a></li>
      <li><a href=https://app.replay.io/recording/eea4aa15-60f6-40e3-872f-0f54f8253bdd>Mocks current user, and updates UI while dev server is running</a></li>
      

View test run on Replay ↗︎

@jtoar jtoar marked this pull request as draft March 17, 2023 20:33
@jtoar jtoar changed the title fix(clerk auth): split setting AuthProvider state fix(clerk auth): set auth state to loading while reAuthenticating Mar 28, 2023
@jtoar jtoar changed the title fix(clerk auth): set auth state to loading while reAuthenticating fix(clerk auth): set auth state to loading while reauthenticating Mar 28, 2023
@jtoar jtoar marked this pull request as ready for review March 28, 2023 21:01
@thedavidprice thedavidprice added this to the next-release-patch milestone Mar 28, 2023
@thedavidprice thedavidprice self-assigned this Mar 28, 2023
@jtoar jtoar enabled auto-merge (squash) April 1, 2023 14:51
@jtoar jtoar merged commit 8b743b9 into main Apr 1, 2023
@jtoar jtoar deleted the ds-fix-clerk-redirecting-again branch April 1, 2023 15:15
jtoar added a commit that referenced this pull request Apr 1, 2023
)

* fix: split setting auth provider state

we know if the user is logged in and auth has loaded before we know the
exact details of the current user, so we can update the state to reflect this
earlier

* Revert "fix: split setting auth provider state"

This reverts commit 05fbe8f.

* fix: start reauthenticate w/ loading to true

* feat: avoid clerk specific logic with new prop

* add comment
@jtoar jtoar modified the milestones: next-release-patch, v4.4.3 Apr 2, 2023
jtoar added a commit that referenced this pull request Apr 2, 2023
)

* fix: split setting auth provider state

we know if the user is logged in and auth has loaded before we know the
exact details of the current user, so we can update the state to reflect this
earlier

* Revert "fix: split setting auth provider state"

This reverts commit 05fbe8f.

* fix: start reauthenticate w/ loading to true

* feat: avoid clerk specific logic with new prop

* add comment
dac09 added a commit to dac09/redwood that referenced this pull request Apr 3, 2023
* 'main' of github.com:redwoodjs/redwood: (66 commits)
  update template README
  bumps API build target 16.20; fixtures updated (redwoodjs#7995)
  remove serverless deploy option (redwoodjs#7993)
  chore(deps): update dependency @clerk/types to v3.33.0 (redwoodjs#7991)
  feat(clerk auth): make `getToken` options globally configurable (redwoodjs#7947)
  chore(deps): update dependency firebase to v9.19.1 (redwoodjs#7986)
  fix(deps): update dependency webpack-dev-server to v4.13.2 (redwoodjs#7989)
  fix(deps): update dependency @clerk/clerk-sdk-node to v4.8.1 (redwoodjs#7988)
  fix upgrade.js error message (redwoodjs#7992)
  fix(clerk auth): set auth state to loading while reauthenticating (redwoodjs#7852)
  chore(deps): update dependency @supabase/supabase-js to v2.13.1 (redwoodjs#7981)
  chore(deps): update dependency @clerk/clerk-react to v4.14.1 (redwoodjs#7987)
  chore: unpublish packages script (redwoodjs#7990)
  chore(deps): update dependency nx to v15.9.2 (redwoodjs#7983)
  chore(deps): update dependency @nrwl/nx-cloud to v15.3.5 (redwoodjs#7985)
  fix(deps): update dependency @apollo/client to v3.7.11 (redwoodjs#7984)
  chore(deps): update dependency @tsd/typescript to v5.0.3 (redwoodjs#7978)
  chore(deps): update dependency typescript to v5.0.3 (redwoodjs#7972)
  chore(deps): update dependency @nrwl/nx-cloud to v15.3.4 (redwoodjs#7977)
  chore(deps): update dependency nx to v15.9.1 (redwoodjs#7976)
  ...
jaiakt pushed a commit to jaiakt/redwood that referenced this pull request Apr 5, 2023
…dwoodjs#7852)

* fix: split setting auth provider state

we know if the user is logged in and auth has loaded before we know the
exact details of the current user, so we can update the state to reflect this
earlier

* Revert "fix: split setting auth provider state"

This reverts commit 05fbe8f.

* fix: start reauthenticate w/ loading to true

* feat: avoid clerk specific logic with new prop

* add comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix This PR is a fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants