Skip to content

Commit

Permalink
fix(nextjs): Drop user, session, organization from auth()
Browse files Browse the repository at this point in the history
  • Loading branch information
panteliselef committed Oct 29, 2023
1 parent a2f451b commit 89f0185
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-phones-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/nextjs': patch
---

Drop `user`, `session`, and `organization` resouces from the returned value of `auth()`.
9 changes: 7 additions & 2 deletions packages/nextjs/src/server/getAuth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Organization, Session, SignedInAuthObject, SignedOutAuthObject, User } from '@clerk/backend';
import type { AuthObject, Organization, Session, SignedInAuthObject, SignedOutAuthObject, User } from '@clerk/backend';
import {
AuthStatus,
constants,
Expand All @@ -18,6 +18,8 @@ import { getAuthKeyFromRequest, getCookie, getHeader, injectSSRStateIntoObject }

type GetAuthOpts = Partial<SecretKeyOrApiKey>;

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

export const createGetAuth = ({
debugLoggerName,
noAuthStatusMessage,
Expand All @@ -26,7 +28,10 @@ export const createGetAuth = ({
debugLoggerName: string;
}) =>
withLogger(debugLoggerName, logger => {
return (req: RequestLike, opts?: GetAuthOpts): SignedInAuthObject | SignedOutAuthObject => {
return (
req: RequestLike,
opts?: GetAuthOpts,
): AuthObjectWithoutResources<SignedInAuthObject | SignedOutAuthObject> => {
const debug = getHeader(req, constants.Headers.EnableDebug) === 'true';
if (debug) {
logger.enable();
Expand Down

0 comments on commit 89f0185

Please sign in to comment.