Skip to content

Commit 4d7ae6b

Browse files
committed
Add changeset
1 parent a7343bb commit 4d7ae6b

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.changeset/flat-papers-begin.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@clerk/backend': minor
3+
'@clerk/express': minor
4+
---
5+
6+
Introduce `treatPendingAsSignedOut` option to `getAuth`
7+
8+
```ts
9+
// `pending` sessions will be treated as signed-out by default
10+
const { userId } = getAuth(req)
11+
```
12+
13+
```ts
14+
// Both `active` and `pending` sessions will be treated as authenticated when `treatPendingAsSignedOut` is false
15+
const { userId } = getAuth(req, { treatPendingAsSignedOut: false })
16+
```

packages/backend/src/tokens/authStatus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function signedIn(
9999
afterSignInUrl: authenticateContext.afterSignInUrl || '',
100100
afterSignUpUrl: authenticateContext.afterSignUpUrl || '',
101101
isSignedIn: true,
102-
// @ts-expect-error Dynamically return `SignedOutAuthObject` based on options
102+
// @ts-expect-error The return type is intentionally overridden here to support consumer-facing logic that treats pending sessions as signed out. This override does not affect internal session management like handshake flows.
103103
toAuth: ({ treatPendingAsSignedOut = true } = {}) => {
104104
if (treatPendingAsSignedOut && authObject.sessionStatus === 'pending') {
105105
return signedOutAuthObject(undefined, authObject.sessionStatus);

packages/express/src/getAuth.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@ export const getAuth = (req: ExpressRequest, options?: GetAuthOptions): AuthObje
2020
throw new Error(middlewareRequired('getAuth'));
2121
}
2222

23-
// this has to receive an option
2423
return req.auth(options);
2524
};

0 commit comments

Comments
 (0)