Skip to content

Commit a5b9528

Browse files
committed
Do not check for sessionClaims on auth state
1 parent 545999c commit a5b9528

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

.changeset/weak-hands-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/nextjs': patch
3+
'@clerk/shared': patch
4+
'@clerk/types': patch
5+
---

packages/nextjs/src/server/data/getAuthDataFromRequest.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ export const getAuthDataFromRequestSync = (
7878
return getAuthObjectFromJwt(jwt, options);
7979
}
8080

81+
console.log('auth object from auth data request', { authObject });
82+
8183
return authObject;
8284
};
8385

@@ -132,6 +134,9 @@ export const getAuthDataFromRequestAsync = async (
132134

133135
// Fallback to session logic (sync version) for all other cases
134136
const authObject = getAuthDataFromRequestSync(req, opts);
137+
138+
console.log('auth data from request', { authObject });
139+
135140
return getAuthObjectForAcceptedToken({ authObject, acceptsToken });
136141
};
137142

packages/shared/src/authorization.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ const prefixWithOrg = (value: string) => value.replace(/^(org:)*/, 'org:');
7575
/**
7676
* Checks if a user has the required organization-level authorization.
7777
* Verifies if the user has the specified role or permission within their organization.
78-
* @returns null, if unable to determine due to missing data or unspecified role/permission.
78+
*
79+
* @returns Null, if unable to determine due to missing data or unspecified role/permission.
7980
*/
8081
const checkOrgAuthorization: CheckOrgAuthorization = (params, options) => {
8182
const { orgId, orgRole, orgPermissions } = options;
@@ -162,7 +163,8 @@ const validateReverificationConfig = (config: ReverificationConfig | undefined |
162163
* Evaluates if the user meets re-verification authentication requirements.
163164
* Compares the user's factor verification ages against the specified maxAge.
164165
* Handles different verification levels (first factor, second factor, multi-factor).
165-
* @returns null, if requirements or verification data are missing.
166+
*
167+
* @returns Null, if requirements or verification data are missing.
166168
*/
167169
const checkReverificationAuthorization: CheckReverificationAuthorization = (params, { factorVerificationAge }) => {
168170
if (!params.reverification || !factorVerificationAge) {
@@ -237,6 +239,7 @@ type AuthStateOptions = {
237239
/**
238240
* Shared utility function that centralizes auth state resolution logic,
239241
* preventing duplication across different packages.
242+
*
240243
* @internal
241244
*/
242245
const resolveAuthState = ({
@@ -306,7 +309,7 @@ const resolveAuthState = ({
306309
} as const;
307310
}
308311

309-
if (!!sessionId && !!sessionClaims && !!userId && !!orgId && !!orgRole) {
312+
if (!!sessionId && !!userId && !!orgId && !!orgRole) {
310313
return {
311314
isLoaded: true,
312315
isSignedIn: true,
@@ -323,7 +326,7 @@ const resolveAuthState = ({
323326
} as const;
324327
}
325328

326-
if (!!sessionId && !!sessionClaims && !!userId && !orgId) {
329+
if (!!sessionId && !!userId && !orgId) {
327330
return {
328331
isLoaded: true,
329332
isSignedIn: true,
@@ -341,4 +344,4 @@ const resolveAuthState = ({
341344
}
342345
};
343346

344-
export { createCheckAuthorization, validateReverificationConfig, resolveAuthState, splitByScope };
347+
export { createCheckAuthorization, resolveAuthState, splitByScope, validateReverificationConfig };

packages/types/src/hooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export type UseAuthReturn =
9494
isSignedIn: true;
9595
userId: string;
9696
sessionId: string;
97-
sessionClaims: JwtPayload;
97+
sessionClaims?: JwtPayload | null;
9898
actor: ActClaim | null;
9999
orgId: null;
100100
orgRole: null;
@@ -108,7 +108,7 @@ export type UseAuthReturn =
108108
isSignedIn: true;
109109
userId: string;
110110
sessionId: string;
111-
sessionClaims: JwtPayload;
111+
sessionClaims?: JwtPayload | null;
112112
actor: ActClaim | null;
113113
orgId: string;
114114
orgRole: OrganizationCustomRoleKey;

0 commit comments

Comments
 (0)