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(nextjs): Drop user, session, organization from auth() #1947

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

panteliselef
Copy link
Member

@panteliselef panteliselef commented Oct 26, 2023

Description

In this PR we are dropping user, session, and organization resouces from the returned value of auth(). They were never officially supported as the middleware didn't support types for loadUser, loadSession.

Although by passing the types errors you could still load the resources. We consider bad practice to have extra 1-3 requests for each request that middleware captures so we should not allow developers to expect the resources returned from auth will be populated.

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/types
  • @clerk/themes
  • @clerk/localizations
  • @clerk/clerk-expo
  • @clerk/backend
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/fastify
  • @clerk/chrome-extension
  • gatsby-plugin-clerk
  • build/tooling/chore

@changeset-bot
Copy link

changeset-bot bot commented Oct 26, 2023

🦋 Changeset detected

Latest commit: 1399570

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@panteliselef panteliselef self-assigned this Oct 26, 2023
@panteliselef panteliselef marked this pull request as ready for review October 26, 2023 19:29
Copy link
Member

@anagstef anagstef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@panteliselef panteliselef added this pull request to the merge queue Oct 29, 2023
@panteliselef panteliselef removed this pull request from the merge queue due to a manual request Oct 29, 2023
@panteliselef panteliselef added this pull request to the merge queue Oct 30, 2023
Copy link
Contributor

@dimkl dimkl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 We should deprecate those return values in v4 before dropping them from auth() in v5.

@dimkl dimkl removed this pull request from the merge queue due to a manual request Oct 30, 2023
@@ -18,6 +18,8 @@ import { getAuthKeyFromRequest, getCookie, getHeader, injectSSRStateIntoObject }

type GetAuthOpts = Partial<SecretKeyOrApiKey>;

type AuthObjectWithoutResources<T extends AuthObject> = Omit<T, 'user' | 'organization' | 'session'>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: we need to rethink how the backend types propagate, as I think we shouldn't resort to this low-level workarounds here. This PR is fine as we need a quick fix, but we should revisit in the future

@panteliselef panteliselef added this pull request to the merge queue Oct 30, 2023
@dimkl dimkl removed this pull request from the merge queue due to a manual request Oct 30, 2023
@dimkl dimkl added this pull request to the merge queue Oct 30, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Oct 30, 2023
@panteliselef panteliselef added this pull request to the merge queue Oct 30, 2023
Merged via the queue into main with commit e5598cf Oct 30, 2023
7 checks passed
@panteliselef panteliselef deleted the SDK-696-deprecate-resources branch October 30, 2023 17:07
tmilewski pushed a commit that referenced this pull request Nov 17, 2023
)

* fix(nextjs): Drop `user`, `session`, `organization` from `auth()`

* fix(nextjs): Typo in changeset
@clerk-cookie
Copy link
Collaborator

This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@clerk clerk locked as resolved and limited conversation to collaborators Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants